我尝试将TestNG与Apache Ivy一起使用,但未成功。这是我的ivy.xml
:
<ivy-module version="2.0">
<info organisation="me" module="myproject"/>
<dependencies>
<dependency org="org.testng" name="testng" rev="5.8" />
</dependencies>
</ivy-module>
这实际上无法下载TestNG jar文件。这似乎是因为TestNG有一个jdk14和jdk15的jar文件。这是ivy:retrieve
的输出:
[ivy:retrieve] :: resolving dependencies :: me#myproject;working@jared-mbp17
[ivy:retrieve] confs: [default]
[ivy:retrieve] found org.testng#testng;5.8 in public
[ivy:retrieve] :: resolution report :: resolve 1139ms :: artifacts dl 11ms
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| default | 1 | 1 | 1 | 0 || 1 | 0 |
---------------------------------------------------------------------
[ivy:retrieve]
[ivy:retrieve] :: problems summary ::
[ivy:retrieve] :::: WARNINGS
[ivy:retrieve] [FAILED ] org.testng#testng;5.8!testng.jar: (0ms)
[ivy:retrieve] ==== shared: tried
[ivy:retrieve] /Users/jared/.ivy2/shared/org.testng/testng/5.8/jars/testng.jar
[ivy:retrieve] ==== public: tried
[ivy:retrieve] http://repo1.maven.org/maven2/org/testng/testng/5.8/testng-5.8.jar
[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve] :: FAILED DOWNLOADS ::
[ivy:retrieve] :: ^ see resolution messages for details ^ ::
[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve] :: org.testng#testng;5.8!testng.jar
[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]
[ivy:retrieve] :: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
在存储库中,您可以看到两个不同的jar文件: http://repo1.maven.org/maven2/org/testng/testng/5.8/testng-5.8-jdk14.jar http://repo1.maven.org/maven2/org/testng/testng/5.8/testng-5.8-jdk15.jar
如何指定jdk14
或jdk15
?
答案 0 :(得分:8)
您需要指定所需工件的分类器。
有一个相关的fix as of 2.1.0-RC1。您可以使用artifact
元素中的元素dependency
来指定所需的classifier
。在这种情况下,分类器应为jdk14
或jdk15
。如果您想要jdk15
,则ivy.xml
将是:
<ivy-module version="2.0"
xmlns:e="http://ant.apache.org/ivy/extra">
<info organisation="me" module="myproject"/>
<dependencies>
<dependency org="org.testng" name="testng" rev="5.8"
transitive="false">
<artifact name="testng" type="jar" ext="jar" e:classifier="jdk15" />
</dependency>
</dependencies>
</ivy-module>
请注意XML名称空间"http://ant.apache.org/ivy/extra"
的规范作为ivy-module
元素的属性。没有它,e:classifier
将无效。