-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle.kts
122 lines (104 loc) · 3.08 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
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
alias(libs.plugins.kotlinGradlePlugin) apply false
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.kotlinBinaryCompatibilityPlugin) apply false
alias(libs.plugins.mavenPublishGradlePlugin) apply false
alias(libs.plugins.versionsGradlePlugin)
alias(libs.plugins.versionCatalogUpdateGradlePlugin)
alias(libs.plugins.dokka)
}
repositories {
mavenCentral()
gradlePluginPortal()
}
buildscript {
repositories {
mavenCentral()
}
}
subprojects {
buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
}
}
repositories {
mavenCentral()
}
apply(plugin = rootProject.project.libs.plugins.kotlinBinaryCompatibilityPlugin.get().pluginId)
apply(plugin = rootProject.project.libs.plugins.mavenPublishGradlePlugin.get().pluginId)
apply(plugin = "version-catalog")
// Only apply if the project has the kotlin plugin added:
plugins.withType<KotlinPluginWrapper> {
val compileKotlin by tasks.getting(KotlinCompile::class) {
kotlinOptions {
jvmTarget = "17"
allWarningsAsErrors = true
}
}
val compileTestKotlin by tasks.getting(KotlinCompile::class) {
kotlinOptions {
jvmTarget = "17"
allWarningsAsErrors = true
}
}
dependencies {
add("testImplementation", project.rootProject.libs.junitApi)
add("testRuntimeOnly", project.rootProject.libs.junitEngine)
}
tasks.withType<GenerateModuleMetadata> {
suppressedValidationErrors.add("enforced-platform")
}
}
tasks.withType<Test> {
dependsOn("apiCheck")
useJUnitPlatform()
testLogging {
events("started", "passed", "skipped", "failed")
exceptionFormat = TestExceptionFormat.FULL
showStandardStreams = false
}
}
apply(plugin = "com.github.ben-manes.versions")
tasks.withType<com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask> {
revision = "release"
resolutionStrategy {
componentSelection {
all {
if (isNonStable(candidate.version) && !isNonStable(currentVersion)) {
reject("Release candidate")
}
}
}
}
}
}
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()
}
// this needs to be defined here for the versionCatalogUpdate
tasks.withType<com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask> {
revision = "release"
resolutionStrategy {
componentSelection {
all {
if (isNonStable(candidate.version) && !isNonStable(currentVersion)) {
reject("Release candidate")
}
}
}
}
}
versionCatalogUpdate {
/**
* Use @pin and @keep in gradle/lib.versions.toml instead of defining here
*/
sortByKey.set(true)
}