build: fix dependency update for non-stable versions

This commit is contained in:
Gauthier Roebroeck 2021-04-27 09:53:47 +08:00
parent 51582ea503
commit 3754c4bbe7
2 changed files with 20 additions and 15 deletions

View File

@ -1,3 +1,5 @@
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
plugins {
run {
val kotlinVersion = "1.4.31"
@ -9,12 +11,30 @@ plugins {
id("com.github.ben-manes.versions") version "0.38.0"
}
fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
val unstableKeyword = listOf("ALPHA", "RC").any { version.toUpperCase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return unstableKeyword || !isStable
}
allprojects {
repositories {
mavenCentral()
}
apply(plugin = "org.jlleitschuh.gradle.ktlint")
apply(plugin = "com.github.ben-manes.versions")
tasks.named<DependencyUpdatesTask>("dependencyUpdates").configure {
// disallow release candidates as upgradable versions from stable versions
rejectVersionIf {
isNonStable(candidate.version) && !isNonStable(currentVersion)
}
gradleReleaseChannel = "current"
checkConstraints = true
}
}
tasks.wrapper {

View File

@ -1,4 +1,3 @@
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import org.apache.tools.ant.taskdefs.condition.Os
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
@ -257,20 +256,6 @@ openApi {
forkProperties.set("-Dspring.profiles.active=claim")
}
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()
}
tasks.named("dependencyUpdates", DependencyUpdatesTask::class.java).configure {
// disallow release candidates as upgradable versions from stable versions
rejectVersionIf {
isNonStable(candidate.version) && !isNonStable(currentVersion)
}
gradleReleaseChannel = "current"
}
configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
version.set("0.40.0")
filter {