-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
91 lines (79 loc) · 2.38 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
91 lines (79 loc) · 2.38 KB
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
import org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.conflicts.DefaultCapabilitiesConflictHandler.candidate
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
alias(libs.plugins.kotlinGradlePlugin) apply false
alias(libs.plugins.kotlinBinaryCompatibilityPlugin) apply false
alias(libs.plugins.versionsGradlePlugin)
alias(libs.plugins.versionCatalogUpdateGradlePlugin)
alias(libs.plugins.dokka)
id("com.vanniktech.maven.publish") apply false
}
repositories {
mavenCentral()
gradlePluginPortal()
}
buildscript {
repositories {
mavenCentral()
}
}
subprojects {
apply(plugin = rootProject.libs.plugins.dokka.get().pluginId)
apply(plugin = rootProject.libs.plugins.kotlinBinaryCompatibilityPlugin.get().pluginId)
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<Test> {
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.toUpperCase().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")
}
}
}
}
}
tasks.register("publishToMavenCentral") {
group = "publishing"
dependsOn(
":lib:publishToMavenCentral",
":testing-lib:publishToMavenCentral",
)
}