How do I set an upper bound on Gradle dynamic versions?

社会主义新天地 提交于 2020-01-04 21:44:46

问题


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?


回答1:


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.


来源:https://stackoverflow.com/questions/23203796/how-do-i-set-an-upper-bound-on-gradle-dynamic-versions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!