-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
156 lines (137 loc) · 4.58 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.kt3k.gradle.plugin.CoverallsPluginExtension
import pl.allegro.tech.build.axion.release.domain.ChecksConfig
import pl.allegro.tech.build.axion.release.domain.RepositoryConfig
import pl.allegro.tech.build.axion.release.domain.TagNameSerializationConfig
// register repositories for both buildscript and application
buildscript.repositories.registerRepositories()
repositories.registerRepositories()
plugins {
kotlin("jvm")
id("pl.allegro.tech.build.axion-release")
`maven-publish`
signing
jacoco
id("com.github.kt3k.coveralls")
}
group = "pt.davidafsilva.jvm.kotlin"
scmVersion {
tag(closureOf<TagNameSerializationConfig> {
prefix = "v"
versionSeparator = ""
})
checks(closureOf<ChecksConfig> {
isUncommittedChanges = false
})
repository(closureOf<RepositoryConfig> {
pushTagsOnly = true
})
}
version = scmVersion.version
dependencies {
api(kotlin("stdlib"))
api(kotlin("reflect"))
val kotestVersion: String by project
testImplementation("io.kotest:kotest-runner-junit5:$kotestVersion")
testImplementation("io.kotest:kotest-assertions-core:$kotestVersion")
}
val javaVersion = JavaVersion.VERSION_1_8
configure<JavaPluginExtension> {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
withSourcesJar()
withJavadocJar()
}
configure<PublishingExtension> {
repositories {
maven {
name = "Sonatype"
val repository = when {
version.toString().endsWith("-SNAPSHOT") -> "/content/repositories/snapshots/"
else -> "/service/local/staging/deploy/maven2/"
}
setUrl("https://s01.oss.sonatype.org/$repository")
credentials {
username = System.getenv("OSSRH_USER")
password = System.getenv("OSSRH_TOKEN")
}
}
}
publications {
create<MavenPublication>("artifacts") {
from(components["java"])
groupId = project.group.toString()
artifactId = project.name
version = project.version.toString()
pom {
val githubRepoUrl = "https://github.com/davidafsilva/pretty-string"
name.set(project.name)
description.set("https://github.com/davidafsilva/pretty-string")
url.set("https://github.com/davidafsilva/pretty-string")
inceptionYear.set("2022")
licenses {
license {
name.set("BSD 3-Clause")
url.set("https://opensource.org/licenses/BSD-3-Clause")
}
}
developers {
developer {
id.set("davidafsilva")
name.set("David Silva")
url.set("https://github.com/davidafsilva")
}
}
scm {
val githubRepoCheckoutUrl = "$githubRepoUrl.git"
connection.set(githubRepoCheckoutUrl)
developerConnection.set(githubRepoCheckoutUrl)
url.set(githubRepoUrl)
}
}
}
}
}
configure<SigningExtension> {
val signingGpgKey: String? by project
val signingGpgKeyId: String? by project
val signingGpgKeyPassword: String? by project
if (signingGpgKey != null && signingGpgKeyId != null && signingGpgKeyPassword != null) {
useInMemoryPgpKeys(signingGpgKeyId, signingGpgKey, signingGpgKeyPassword)
}
sign(publishing.publications.getByName("artifacts"))
}
tasks {
withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = javaVersion.toString()
}
}
withType<Jar> {
from("${projectDir}/LICENSE") {
rename("LICENSE", "META-INF/LICENSE.txt")
}
}
withType<JacocoReport> {
reports {
xml.required.set(true)
html.required.set(true)
}
}
configure<CoverallsPluginExtension> {
sourceDirs = sourceDirs + "src/main/kotlin"
}
withType<Test> {
useJUnitPlatform()
}
val testCoverage = register("testCoverage") {
dependsOn("test", ":jacocoTestReport", ":jacocoTestCoverageVerification")
group = "verification"
description = "Runs both the coverage report and validation"
}
findByName("test")!!.finalizedBy(testCoverage)
}
fun RepositoryHandler.registerRepositories() {
mavenLocal()
mavenCentral()
}