Last active
March 24, 2023 14:55
-
-
Save G00fY2/c852322a18b187f40bb884a85065c57f to your computer and use it in GitHub Desktop.
Check for unstable dependencies in Gradle configurations which where implicitly resolved
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
configurations.configureEach { | |
if (this.name.contains("Compile") && !this.name.contains("TestCompile")) { | |
this.incoming.afterResolve { | |
this.resolutionResult.allComponents { | |
if (this.selectionReason.isConflictResolution && | |
this.moduleVersion?.version.let { | |
it != null && isNonStable(it) | |
} | |
) { | |
throw GradleException( | |
"Unstable transitive dependency in ${[email protected]} found: " + | |
"${this.moduleVersion?.group}:${this.moduleVersion?.name}:${this.moduleVersion?.version}. " + | |
"Check your dependency graph." | |
) | |
} | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val preReleaseQualifiersPattern: List<Regex> = | |
listOf("preview", "dev", "alpha", "beta", "m", "cr", "rc") | |
.map { ".*[.\\-]$it([.\\-\\d]*|[.\\-\\d]+.*)".toRegex(RegexOption.IGNORE_CASE) } | |
public fun isNonStable(version: String): Boolean { | |
return preReleaseQualifiersPattern.any { version.matches(it) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment