In gradle 6.7.1 I am trying to use strictly
to specify a range of versions for a transitive dependency.
In the documentation linked above, it says
For example, [...] instead of
strictly 1.0
, that it strictly depends on the[1.0, 2.0[
range, but prefers1.0
.
I am trying what was suggested, where I want to specify a range with a minimum version but no maximum version. I do it as below:
def LIB_MIN_VERSION = '2.16.0'
testCompile('some-library') {
version {
strictly [LIB_MIN_VERSION,)
}
}
From the documentation on versioning, )
means an exclusive bound, and when an upper bound is missing, there is no upper bound.
When I run ./gradlew dependencies
, I get this error:
> startup failed: build file '/home/shane/src/flink-svc/build.gradle': 119: expecting ']', found ')' @ line 119, column 33. strictly [LIB_MIN_VERSION,) ^
If I change to strictly [LIB_MIN_VERSION,]
and rerun, I instead get this error:
> Could not get unknown property 'strictly' for of type org.gradle.api.internal.artifacts.dependencies.DefaultMutableVersionConstraint.
Is it possible this range feature isn't available in my version of gradle? Or am I making a syntax error?
I tried @Slaw's suggestion to quote the range as strictly '[LIB_MIN_VERSION,)'
. When I do, I don't get an error running ./gradlew dependencies
, but in the output the resolution shows as failed:
some-library:{strictly [LIB_MIN_VERSION,)} FAILED
If I use strictly LIB_MIN_VERSION
without a range (with is undesirable), then I don't get FAILED
:
some-library:{strictly 2.16.0} -> 2.16.0
The dependency resolution also shows as FAILED
if I try using Groovy string interpolation with strictly "[${LOG4J_LIB_VERSION},)"
:
some-library:{strictly [2.16.0,)} FAILED
The problem (as far as I can tell) was that this syntax was not supported by Gradle 6.7.1. Once I upgraded to 7.0, it worked using Groovy string interpolation, as below:
strictly "[${LOG4J_LIB_VERSION},)"