Maven版本范围排除下一个次要版本 [英] Maven Version Range To Exclude Next Minor Version

查看:488
本文介绍了Maven版本范围排除下一个次要版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Maven 3.3.3,并想表示我将接受jackson-core依赖关系的任何2.7.x版本(但在有机会评估以下条件之前,我不愿意使用2.8.x)向后兼容性,运行单元/回归测试等).

I am using Maven 3.3.3 and want to express that I will accept any 2.7.x version of the jackson-core dependency (but am not willing to go to 2.8.x until I've had a chance to assess for backward compatibility, run unit / regression tests, etc.).

这将使我的项目能够收到错误修复(在增量版本下),但会延迟到下一个minor版本的跳转,直到准备就绪为止.

This would allow my project to receive bug fixes (under incremental versions), but delay the jump to the next minor version until ready.

我本能地将以下内容写到pom.xml:

I instinctively wrote the following into pom.xml:

<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>[2.7.1,2.8)</version>

但是,mvn dependency:list表示使用了以下版本:

However, a mvn dependency:list says that the following version is used:

com.fasterxml.jackson.core:jackson-core:jar:2.8.0.rc2:compile

我对此感到吃惊,但是挖出了此答案,导致了官方" Maven Javadoc 描述了Maven依赖项的排序顺序.

I was taken aback by that, however dug up this answer which leads to the "official" Maven Javadoc which describes the sort order of Maven dependencies.

那些帮助我理解了为什么2.8.0.rc2被认为比2.8.0旧"的原因.

Those helped me understand why 2.8.0.rc2 is considered "older" than 2.8.0.

因此,我认为以下内容(尽管有点骇人听闻)会产生预期的结果: [2.7.1,2.8.0.a)

So, I reasoned that the following would (albeit hack-ishly) produce the desired results: [2.7.1,2.8.0.a)

我错了. dependency:list现在产生:

com.fasterxml.jackson.core:jackson-core:jar:2.8.0:compile

与的结果相同(或与-a相同的结果): [2.7.1,2.8.a)

Same result with (or variations with -a): [2.7.1,2.8.a)

总的来说,这似乎暗示着以下顺序:

All together, this seems to imply the following orderings:

2.8.0 < 2.8.0.a 
2.8.0.rc2 < 2.8.0 

所以...如果我在学校学到的关于及物关系的一切都是正确的,那么:

So ... if everything I learned in school about transitive relationships is correct, then:

2.8.0.rc2 < 2.8.0.a

这似乎与SO答案相矛盾.同时,Javadoc模棱两可(即在实际上实施的排序中列出了限定词的排序)和此Apache Wiki/Confluence页面有点令人困惑.

That seems to contradict the SO answer. At the same time, the Javadoc is ambiguous (i.e. is the qualifier ordering listed the actually implemented ordering) and this Apache Wiki / Confluence page is mildly confusing.

无论如何,排序候选"(假定rc的含义应早于指定为a的alpha版本)似乎与String排序或常识都没有一致.

Regardless, it doesn't seem to line up with either String sorting or common sense that a "Release Candidate" (assumed meaning for rc would precede an alpha version specified as a).

如果已经发布了实际的2.8.0-alpha版本,将对此进行不同的处理吗?

Would this be handled differently if there an actual 2.8.0-alpha version had been released?

底线:有没有一种合理的可转移方式来指定Maven版本范围,该版本范围不包括2.8.0版本空间中的所有内容?

Bottom line: is there a reasonably transferable way to specify a Maven Version Range which excludes everything in the 2.8.0 version space?

更重要的是...在其源代码之外的Maven版本排序算法 中是否有记录明确且可公开获得的描述?很难判断cwiki页面是否是所需的规范或实现的(当然并没有达到我们在此处探讨的详细程度),并且Javadoc似乎暗示了(但并没有明确说明)等同性在.-之间,这里的注释表明不是这种情况.

Even more bottom line... is there a clearly documented and publicly available description of the Maven version ordering algorithm outside of their source code? It's hard to tell if the cwiki page is a desired spec or implemented (and certainly doesn't go to the level of detail we're exploring here) and the Javadoc seems to imply (but isn't unambiguous in stating so) the equality between . and - which comments here demonstrate is not the case.

推荐答案

您可以使用以下命令简单地检查顺序:

You can simply check the ordering by using the following command:

java -jar apache-maven-3.3.3/lib/maven-artifact-3.3.3.jar 2.8.0.rc2 2.8.0.a

Display parameters as parsed by Maven (in canonical form) and comparison result:
1. 2.8.0.rc2 == 2.8.0.rc-2
   2.8.0.rc2 < 2.8.0.a
2. 2.8.0.a == 2.8.0.a

您还可以通过以下方式检查其他版本2.8.0-alpha:

You can also check the other version 2.8.0-alpha via:

java -jar apache-maven-3.3.3/lib/maven-artifact-3.3.3.jar 2.8.0.rc2 2.8.0-alpha
Display parameters as parsed by Maven (in canonical form) and comparison result:
1. 2.8.0.rc2 == 2.8.0.rc-2
   2.8.0.rc2 > 2.8.0-alpha
2. 2.8.0-alpha == 2.8-alpha

这篇关于Maven版本范围排除下一个次要版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆