Question

I can't find any explicit documentation on Gradle dynamic version syntax -- the examples in the official docs are 1.+ and 2.+, neither of which appears to have an upper bound.

Say I have 1.0-SNAPSHOT and 2.0-SNAPSHOT in my repository, and I want a certain project to pull in the first or any future stable 1.x, but not the second.

I've tried both Maven syntax ([1.0,2.0)) and Ivy syntax ([1.0,2.0[). Both of these pull in 2.0-SNAPSHOT. Why? Is 2.0-SNAPSHOT considered "less than" 2.0?

On that assumption, I tried the obvious hacks: [1.0,2.0-SNAPSHOT) and [1.0,2.0-SNAPSHOT[, but both of those just fail dependency resolution.

How can I tell Gradle I only want version 1.x?

Was it helpful?

Solution

Looks like the answer is that + includes an implicit upper bound. So 1.+ means "any version that starts with 1."

This doesn't seem to be anywhere in the Gradle docs, but it is documented for Ivy:

  • end the revision with a +
    selects the latest sub-revision of the dependency module. For instance, if the dependency module exists in revision 1.0.3, 1.0.7 and 1.1.2, "1.0.+" will select 1.0.7.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top