如何在Apache Ivy中使用TestNG?

时间:2009-04-18 00:52:31

标签: java ant ivy testng

我尝试将TestNGApache 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

如何指定jdk14jdk15

1 个答案:

答案 0 :(得分:8)

您需要指定所需工件的分类器。

有一个相关的fix as of 2.1.0-RC1。您可以使用artifact元素中的元素dependency来指定所需的classifier。在这种情况下,分类器应为jdk14jdk15。如果您想要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将无效。