-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
41 lines (38 loc) · 1.78 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
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.kover)
alias(libs.plugins.versionsBenManes)
alias(libs.plugins.versionCatalogUpdate)
alias(libs.plugins.android.application) apply false
alias(libs.plugins.jetbrains.kotlin.android) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.hilt.plugin) apply false // fun https://github.com/google/dagger/issues/3068
}
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 {
when {
isNonStable(candidate.version) && !isNonStable(currentVersion) -> {
reject("Updating stable to non stable is not allowed")
}
candidate.module == "kotlin-gradle-plugin" && candidate.version != libs.versions.kotlin.get() -> {
reject("Keep Kotlin version on the version specified in libs.versions.toml")
}
// KSP versions are compound versions, starting with the kotlin version
candidate.group == "com.google.devtools.ksp" && !candidate.version.startsWith(libs.versions.kotlin.get()) -> {
reject("KSP needs to stick to Kotlin version")
}
}
}
}
}
}