-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
123 lines (106 loc) · 3.33 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
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
kotlin("jvm") version "2.1.0"
jacoco
id("com.github.ben-manes.versions") version "0.51.0"
id("io.gitlab.arturbosch.detekt") version "1.23.7"
// publishing
`java-library`
`maven-publish`
signing
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
}
kotlin {
jvmToolchain(8)
}
repositories {
mavenCentral()
}
dependencies {
// JUnit 5 test discovery
implementation("org.junit.platform:junit-platform-launcher:1.11.3")
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.7")
}
tasks.named("compileKotlin", org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask::class.java) {
compilerOptions {
freeCompilerArgs.add("-Xjsr305=strict")
kotlin.compilerOptions.jvmTarget = JvmTarget.JVM_1_8
}
}
tasks.withType<Detekt>().configureEach {
reports {
xml.required.set(false)
html.required.set(false)
txt.required.set(false)
sarif.required.set(false)
md.required.set(false)
}
}
detekt {
autoCorrect = true
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<DependencyUpdatesTask> {
rejectVersionIf {
isNonStable(candidate.version)
}
gradleReleaseChannel = "current"
}
fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
}
java {
withJavadocJar()
withSourcesJar()
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
pom {
name.set("Greencently")
description.set("Optimize your pre-commit hook's test run. All tests green, recently? Commit quickly and stay in flow.")
url.set("https://schmonz.com/software/greencently")
licenses {
license {
name.set("The Unlicense")
url.set("https://unlicense.org")
}
}
developers {
developer {
id.set("schmonz")
name.set("Amitai Schleier")
email.set("schmonz-web-greencently@schmonz.com")
}
}
scm {
connection.set("scm:git:git@github.com:schmonz/junit-greencently.git")
developerConnection.set("scm:git:git@github.com:schmonz/junit-greencently.git")
url.set("https://github.com/schmonz/junit-greencently.git")
}
}
}
}
}
nexusPublishing {
this.repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}
signing {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications["mavenJava"])
}