0
votes

We are moving from Ant w/ Ivy to Maven. As part of this move, we have taken projects with multiple jars that use to be separate Ivy artifacts into Maven artifacts with classifiers.

The new Maven projects have no problems with this. However, our Ivy projects can't locate the pom.xml for the classifier.

In our Maven repository, their is a single pom.xml for all of the jars in the project:

http://repo.vegicorp.com/l/com/vegicorp/foo/1.0.0/foo-1.0.0.pom
http://repo.vegicorp.com/l/com/vegicorp/foo/1.0.0/foo-1.0.0.jar
http://repo.vegicorp.com/l/com/vegicorp/foo/1.0.0/foo-1.0.0-client.jar
http://repo.vegicorp.com/l/com/vegicorp/foo/1.0.0/foo-1.0.0-test.jar

Looking at the output of an debug Ant build, I see that it's looking in our Maven repository at:

http://repo.vegicorp.com/com/vegicorp/foo/1.0.0/foo-1.0.0-client.pom

It's appending the classifier to the name of the pom.xml file! It can find and download the jar, but without the pom.xml, it can't figure out the dependencies. Our build fails because the dependencies aren't downloaded.

I assume there's some setting in ivysettings.xml that will let Ivy know that Pom files don't have the classifier appended to them, but I haven't figured it out.

So, how do I fix this issue? I might be able to copy the missing pom.xml into our Repository (This is Artifactory), but I am not sure if I can. (Maybe there's a setting in Artifactory that can help resolve this?).

2

2 Answers

0
votes

You need to say to ivy to use lBiblio resolver. You can disable looking for poms, quote from lBilbio link:

When using the m2compatible flag, you can disable the use of poms by setting the usepoms flag to false

If that one doesn't work, more refined settings can be achieved with packager resolver - at the bottom of the page there is a not on classifier attribute.

In addition (for any resolver), you may need to set up artifact pattern properly to actually find the artifacts.

0
votes

I've found a work around, or maybe this is the way I should have been doing it the whole time.

I was defining the dependencies in my ivy.xml files this way:

<dependency org="com.vegicorp" name="foo" version="1.0"
    conf="compile->default"/>

Everything is under the <dependency> entity and no sub-entities and it worked just fine. By default, it found the pom.xml, converted it into an ivy.xml dependency file, and downloaded the jar too.

When we started adding the classifier, we did it this way:

<dependency org="com.vegicorp" name="foo" version="1.0"
    conf="compile->default" maven:classifier="client"/>

Again, putting everything inside the <dependency> entity with no sub-entities. Ivy then looks for the jar at com/vegicorp/foo/1.0.0/foo-1.0.0-client.jar which is correct, but can't locate the POM at com/vegicorp/foo/1.0.0/foo-1.0.0-client.com. We never noticed this before because we only had two or three third party jars that had classifiers, and none of these jars had dependencies on other jars. It didn't matter that the jar downloaded without the associated POM.

Everything broke when we started defining our own jars with classifiers because our jars had other jar dependencies.

However, if I used the <artifact> entity and put the classifier in that, everything worked:

<dependency org="com.vegicorp" name="foo" version="1.0" 
    conf="compile->default">
    <artifact name="foo" ext="jar" maven:classifier="client"/>
</dependency>

Ivy finds the correct location in the repository at com/vegicorp/foo/1.0.0, and then downloads the POM without the classifier at com/vegicorp/foo/1.0.0/foo-1.0.0.pom. It then locates the artifact at this location with the classifer at com/vegicorp/foo/1.0.0/foo-1.0.0-client.jar