Skip to content

Instantly share code, notes, and snippets.

@msfjarvis
Last active January 5, 2022 04:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msfjarvis/9f7ed2bb0078681f4c9f2aca83a3ffe6 to your computer and use it in GitHub Desktop.
Save msfjarvis/9f7ed2bb0078681f4c9f2aca83a3ffe6 to your computer and use it in GitHub Desktop.
Gradle init script to configure `com.github.ben-manes:gradle-versions-plugin`
initscript {
repositories { gradlePluginPortal() }
dependencies { classpath("com.github.ben-manes:gradle-versions-plugin:0.41.0") }
}
allprojects {
apply<com.github.benmanes.gradle.versions.VersionsPlugin>()
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.withType<com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask> {
if (project.providers.gradleProperty("stable").forUseAtConfigurationTime().isPresent()) {
rejectVersionIf {
isNonStable(candidate.version) && !isNonStable(currentVersion)
}
}
checkForGradleUpdate = false
checkBuildEnvironmentConstraints = true
outputFormatter = "json"
outputDir = "build/dependencyUpdates"
reportfileName = "report"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment