-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
152 lines (125 loc) · 4.01 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
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
plugins {
kotlin("jvm") version "1.9.25"
id("com.diffplug.spotless") version "6.25.0"
id("io.gitlab.arturbosch.detekt") version "1.23.8"
id("com.github.ben-manes.versions") version "0.51.0"
id("org.jetbrains.dokka") version "1.9.20"
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
id("maven-publish")
id("signing")
}
java { toolchain.languageVersion.set(JavaLanguageVersion.of(11)) }
val pomDesc =
"A very small boilerplate-free kotlin library to read values " +
"from environment variables in a typesafe way"
val artifactName = "envkeg"
val artifactGroup = "de.breuco"
group = artifactGroup
val artifactVersion = "0.6.1"
version = artifactVersion
spotless {
val ktfmtVersion = "0.37"
kotlin { ktfmt(ktfmtVersion).googleStyle() }
kotlinGradle {
target("*.gradle.kts")
ktfmt(ktfmtVersion).googleStyle()
}
}
detekt {
buildUponDefaultConfig = true
allRules = true
config = files("$projectDir/detekt.yaml")
}
fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
}
tasks.named("dependencyUpdates", DependencyUpdatesTask::class.java).configure {
rejectVersionIf { isNonStable(candidate.version) }
revision = "release"
gradleReleaseChannel = "current"
}
tasks.wrapper { distributionType = Wrapper.DistributionType.ALL }
repositories { mavenCentral() }
dependencies {
val kotestVersion = "5.9.1"
testImplementation("io.kotest:kotest-runner-junit5-jvm:$kotestVersion") {
exclude("junit")
exclude("org.junit.vintage")
}
testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.12.1")
testImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0")
testImplementation("org.mockito:mockito-inline:5.2.0")
testImplementation("uk.org.webcompere:system-stubs-jupiter:2.1.7")
}
kotlin { explicitApi() }
tasks.test { useJUnitPlatform() }
val dokkaJar by
tasks.creating(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles Kotlin docs with Dokka"
archiveClassifier.set("javadoc")
from(tasks.dokkaJavadoc)
}
val sourcesJar by
tasks.creating(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles sources JAR"
archiveClassifier.set("sources")
from(sourceSets["main"].allSource)
}
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}
publishing {
publications {
afterEvaluate {
create<MavenPublication>("mavenJava") {
groupId = artifactGroup
artifactId = artifactName
version = version
from(components["java"])
artifact(sourcesJar)
artifact(dokkaJar)
pom {
name.set(artifactName)
description.set(pomDesc)
url.set("https://github.com/breucode/envkeg")
licenses {
license {
name.set("MIT License")
url.set("https://github.com/breucode/envkeg/blob/master/LICENSE")
}
}
developers {
developer {
id.set("breucode")
name.set("Pascal Breuer")
email.set("[email protected]")
}
}
scm {
url.set("https://github.com/breucode/envkeg/tree/master")
connection.set("scm:git:github.com:breucode/envkeg.git")
developerConnection.set("scm:git:ssh://github.com:breucode/envkeg.git")
}
}
}
}
}
}
signing {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications)
}