0

I need to resolve maven test-jar dependencies from ivy project. Retrieving the jars is no problem, but the test-jars are not resolved for some reason...

Here is my resolver

<ibiblio name="nexus" root="${nexus-maven2-root}" pattern="${nexus-maven2-pattern}" m2compatible="true"/>

 <property name="nexus-maven2-pattern"
          value="[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"
          override="false" />

In nexus, this artifact is resolved (IBSCore-2.21-20160825.121144-2.jar) but this one not (IBSCore-2.21-20160825.121144-2-tests.jar).

Thanks a lot for your help already!

user6761124
  • 117
  • 12

2 Answers2

0

Firstly I'm guessing this is a module with a snapshot revision? What is your dependency declaration in ivy look like?

This is my best guess:

<dependency org="group.goes.here" name="IBSCore" rev="2.21-SNAPSHOT" />

Secondly the tests jar looks like an additional module artifact, something that in Maven would be referenced using a "classifier", for example:

<dependency>
    <groupId>group.goes.here</groupId>
    <artifactId>IBSCore</artifactId>
    <version>2.21-SNAPSHOT</version>
    <classifier>tests</classifier>
</dependency>

So, if I'm correct, you can retrieve both files, by explicitly stating them in the ivy dependency:

<dependency org="group.goes.here" name="IBSCore" rev="2.21-SNAPSHOT">
    <artifact name="IBSCore" type="jar" />
    <artifact name="IBSCore" type="jar" m:classifier="tests"/>
</dependency>

The syntax is odd because, unlike Ivy, a Maven module's metadata does not explicitly list all the files that it contains. When Ivy downloads from a Maven repository the only additional files it has support for are source and javadoc jars. For more painful detail, see:

Community
  • 1
  • 1
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
0

The real cause of the problem was actually that I had some nasty ant tasks doing the following :

 <target name="-do-resolve-ivy-dependencies" unless="ivy.cached">
    <ivy:resolve conf="default, test, test-utils" type="jar, war, bundle" log="download-only" checkIfChanged="false"/>
    <ivy:cachefileset setid="default.libs.id" conf="default" log="download-only"/>
    <ivy:cachefileset setid="test.libs.id" conf="test, test-utils" log="download-only"/>

    <path id="default.libs.path">
        <fileset refid="default.libs.id"/>
    </path>
    <path id="test.libs.path">
        <fileset refid="test.libs.id"/>
    </path>
</target>

So the type "test-jar" wasn't resolved. Adding this did the trick.

user6761124
  • 117
  • 12
  • You could use the ivy cachepath task to create the Ant path in a single step http://ant.apache.org/ivy/history/latest-milestone/use/cachepath.html – Mark O'Connor Aug 31 '16 at 06:46