I am using gradle with dynamic versioning , i.e. something like this
dependencies {
compile("myGroup:myModule:1.9.+")
}
I would like to reject any SNAPSHOT canidates, such that the above example would match 1.9.1 but would reject 1.9.2-SNAPSHOT, except for the case that somebody explicitly required it.
So far, we worked with something like
resolutionStrategy.componentSelection {
all { ComponentSelection selection ->
if (selection.candidate.version.endsWith("-SNAPSHOT")){
selection.reject("Rejecting changing version (SNAPSHOT)'")
}
}
}
This rejects all canididates ending in SNAPSHOT.
I learned that one can also access requested version using something like this
resolutionStrategy.eachDependency { details ->
if (details.requested.version.endsWith("-SNAPSHOT")) {
...
}
}
Is there a way to combine the two into something like this?
if (selection.candidate.version.endsWith("-SNAPSHOT") && ! details.requested.version.endsWith("-SNAPSHOT")) {
selection.reject("Rejecting changing version (SNAPSHOT)'")
}