Skip to content

Commit 21b65c6

Browse files
Build: add versions plugin [0.51.0]
1 parent be68161 commit 21b65c6

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

build.gradle.kts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// - sonatypePassword: Maven Central credential used by Nexus publishing.
77

88
plugins {
9+
// https://github.com/ben-manes/gradle-versions-plugin/releases
10+
id("com.github.ben-manes.versions") version "0.51.0"
911
// https://github.com/spotbugs/spotbugs-gradle-plugin/releases
1012
id("com.github.spotbugs") version "5.0.14" apply false
1113
// https://github.com/gradle-nexus/publish-plugin/releases
@@ -96,6 +98,19 @@ allprojects {
9698
}
9799
}
98100

101+
// Exclude pre-release versions from dependencyUpdates task
102+
fun isNonStable(version: String): Boolean {
103+
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) }
104+
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
105+
val isStable = stableKeyword || regex.matches(version)
106+
return isStable.not()
107+
}
108+
tasks.withType<com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask> {
109+
rejectVersionIf {
110+
isNonStable(candidate.version)
111+
}
112+
}
113+
99114
tasks.wrapper {
100115
distributionType = Wrapper.DistributionType.ALL
101116
}

0 commit comments

Comments
 (0)