Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use TestNG with Apache Ivy?

Tags:

java

ant

testng

ivy

I tried to use TestNG with Apache Ivy, but was unsuccessful. Here is my 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>

This fails to actually download a TestNG jarfile. It seems to be because TestNG has a jarfile for jdk14 and jdk15. Here's the output from 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

In the repository you can see two different jarfiles: 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

How do I specify either jdk14 or jdk15?

like image 498
Jared Oberhaus Avatar asked Apr 18 '09 00:04

Jared Oberhaus


People also ask

How do I run Ivy XML?

Building the project Just go the console. Navigate to E: > ivy folder and run the ant command. Ivy will come into action, resolving the dependencies, you will see the following result. You can verify the downloaded files in ivy cache's default local repository location ${ivy.

What is Ivy in Java?

Ivy is a dependency manager -- it manages and controls the JAR files that your project depends on. If you don't have the JARs, it will pull them down for you by default (from the Maven 2 repository), which can make project setup a lot easier. Copy link CC BY-SA 2.5.


1 Answers

You need to specify the classifier of the artifact you want.

There is a related fix as of 2.1.0-RC1. You can use the element artifact within the dependency element to specify the classifier you want. In this case, the classifier should be jdk14 or jdk15. If you want jdk15 your ivy.xml would then be:

<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>

Note the specification of the XML namespace "http://ant.apache.org/ivy/extra" as an attribute of the ivy-module element. Without that the e:classifier won't work.

like image 128
Jared Oberhaus Avatar answered Sep 28 '22 01:09

Jared Oberhaus