-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
81 lines (70 loc) · 2.27 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
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
plugins {
id("org.jetbrains.kotlin.jvm") version "2.0.21"
id("se.patrikerdes.use-latest-versions") version "0.2.18"
id("com.github.ben-manes.versions") version "0.51.0"
id("com.adarshr.test-logger") version "4.0.0"
id("com.diffplug.spotless") version "6.25.0"
id("org.sonarqube") version "5.1.0.4882"
application
}
repositories {
mavenCentral()
maven { url = uri("https://plugins.gradle.org/m2") }
}
dependencies {
implementation("com.fasterxml.jackson.core:jackson-databind:2.18.1")
implementation("org.jetbrains.kotlin:kotlin-stdlib")
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
testImplementation("com.github.tomakehurst:wiremock-jre8:3.0.1")
}
application {
mainClass.set("pullpitok.AppKt")
}
kotlin {
jvmToolchain {
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(21))
}
}
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()
}
tasks.withType<DependencyUpdatesTask> {
resolutionStrategy {
componentSelection {
all {
if (isNonStable(candidate.version) && !isNonStable(currentVersion)) {
reject("Release candidate")
}
}
}
}
}
spotless {
kotlin {
ktlint()
}
kotlinGradle {
// same as kotlin, but for .gradle.kts files (defaults to '*.gradle.kts')
target("*.gradle.kts")
ktlint()
}
}
tasks.register<Jar>("uberJar") {
manifest {
attributes["Implementation-Title"] = "PullpitoK"
attributes["Implementation-Version"] = archiveVersion
attributes["Main-Class"] = "pullpitok.AppKt"
}
archiveClassifier.set("all")
duplicatesStrategy = DuplicatesStrategy.INCLUDE
from(sourceSets.main.get().output)
dependsOn(configurations.runtimeClasspath)
from({
configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
})
}