-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.gradle.kts
153 lines (135 loc) · 4.11 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
import de.fayard.refreshVersions.core.versionFor
plugins {
kotlin("jvm")
id("org.jetbrains.dokka")
jacoco
id("org.jlleitschuh.gradle.ktlint")
id("io.gitlab.arturbosch.detekt")
`maven-publish`
signing
id("io.github.gradle-nexus.publish-plugin")
}
val myGroup = "com.github.pgreze".also { group = it }
val myArtifactId = "kotlin-process"
val tagVersion = System.getenv("GITHUB_REF")?.split('/')?.last()
val myVersion = (tagVersion?.trimStart('v') ?: "WIP").also { version = it }
val myDescription = "Kotlin friendly way to run an external process".also { description = it }
val githubUrl = "https://github.com/pgreze/$myArtifactId"
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withSourcesJar()
withJavadocJar()
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
tasks.test {
useJUnitPlatform()
finalizedBy(tasks.jacocoTestReport)
}
jacoco {
toolVersion = "0.8.7"
}
tasks.jacocoTestReport {
reports {
xml.required.set(true)
html.required.set(System.getenv("CI") != "true")
}
}
configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
version.set(versionFor("version.com.pinterest.ktlint..ktlint-cli"))
}
dependencies {
setOf(
kotlin("stdlib-jdk8"),
KotlinX.coroutines.core,
).forEach { dependency ->
compileOnly(dependency)
testImplementation(dependency)
}
// To trigger refreshVersions updates
"ktlint"("com.pinterest.ktlint:ktlint-cli:_")
testImplementation("org.amshove.kluent:kluent:_")
testImplementation(platform(Testing.junit.bom))
testImplementation("org.junit.jupiter:junit-jupiter-api")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testImplementation("org.junit.jupiter:junit-jupiter-params")
}
//
// Publishing
//
val propOrEnv: (String, String) -> String? = { key, envName ->
project.properties.getOrElse(key, defaultValue = { System.getenv(envName) })?.toString()
}
val ossrhUsername = propOrEnv("ossrh.username", "OSSRH_USERNAME")
val ossrhPassword = propOrEnv("ossrh.password", "OSSRH_PASSWORD")
publishing {
publications {
create<MavenPublication>("maven") {
groupId = myGroup
artifactId = myArtifactId
version = myVersion
from(components["java"])
pom {
name.set(myArtifactId)
description.set(myDescription)
url.set(githubUrl)
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("pgreze")
name.set("Pierrick Greze")
}
}
scm {
connection.set("$githubUrl.git")
developerConnection.set("scm:git:ssh://github.com:pgreze/$myArtifactId.git")
url.set(githubUrl)
}
}
}
}
repositories {
maven {
name = "sonatype"
setUrl("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = ossrhUsername
password = ossrhPassword
}
}
}
}
mapOf(
"signing.keyId" to "SIGNING_KEY_ID",
"signing.password" to "SIGNING_PASSWORD",
"signing.secretKeyRingFile" to "SIGNING_SECRET_KEY_RING_FILE",
).forEach { (key, envName) ->
val value = propOrEnv(key, envName)
?.let {
if (key.contains("File")) {
rootProject.file(it).absolutePath
} else {
it
}
}
ext.set(key, value)
}
signing {
sign(publishing.publications)
}
nexusPublishing {
packageGroup.set(myGroup)
repositories {
sonatype {
username.set(ossrhUsername)
password.set(ossrhPassword)
}
}
}