如何设置Gradle动态版本的上限? [英] How do I set an upper bound on Gradle dynamic versions?
问题描述
我无法在Gradle动态版本语法中找到任何明确的文档 - 官方文档是 1。+
和 2。+
,两者似乎都没有假设我有 1.0-SNAPSHOT
和 2.0-SNAPSHOT code>在我的仓库中,我想要一个特定的项目将第一个或拉入任何未来的稳定
1.x
中,但不能第二。
我已经尝试了 Maven语法( [1.0,2.0)
)和常青藤语法( [1.0,2.0 [
))。这两个都拉入 2.0-SNAPSHOT
。为什么? 2.0-SNAPSHOT
被视为小于 2.0
?
<在这个假设下,我尝试了很明显的窍门:
[1.0,2.0-SNAPSHOT)
和 [1.0,2.0-SNAPSHOT [$ c
如何告诉Gradle我只想要版本 1.x
解决方案看起来像答案是 +
包含一个隐含的上界。所以 1。+
表示任何以 1开头的版本。
这似乎没有在Gradle文档中的任何地方,但它记录为常春藤:
-
选择依赖模块的最新子版本。例如,
(如果版本1.0.3,1.0.7和1.1.2中存在依赖关系模块,1.0。+将选择1.0.7。)
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
?
解决方案 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.
这篇关于如何设置Gradle动态版本的上限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!