我正在尝试使用 Maven 依赖插件来获取特定版本范围内的 Artifact 。我需要在命令行(或在脚本中)执行此操作
这是我尝试过的:
mvn dependency:get -Dartifact="junit:junit:[4.0,4.11)"
但是,该范围显然未被识别。 Maven 尝试下载文字版本为 [4.0.0,4.11.0) 的 Artifact ,但失败了。
我想我使用了错误的语法和/或没有正确转义。
我怎样才能让maven获取符合指定版本范围的最高版本的 Artifact ?
错误消息:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:get (default-cli) on project standalone-pom: Couldn't download artifact: Missing:
[ERROR] ----------
[ERROR] 1) junit:junit:jar:[4.0,4.11)
最佳答案
此目标不支持版本范围:
https://issues.apache.org/jira/browse/MDEP-88
我得到:
Failed to retrieve POM for junit:junit:jar:[4.0,4.11): Could not transfer artifact junit:junit:pom:[4.0,4.11) from/to central (https://repo.maven.apache.org/maven2): Illegal character in path at index 49: https://repo.maven.apache.org/maven2/junit/junit/[4.0,4.11)/junit-[4.0,4.11).pom
所以范围没有被解析。
不确定有什么替代方案可以完成完全相同的事情:/
版本插件允许解析范围 http://www.mojohaus.org/versions-maven-plugin/resolve-ranges-mojo.html但仅限于 pom.xml 中 - 需要创建一个假 pom.xml - 使用此插件来解析版本,然后从创建的 pom 中获取它 - 希望有更好的方法...
关于maven - 如何在命令行上指定 Maven 依赖插件 get 的版本范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31006870/