Publishing Ivy SNAPSHOTS with Maven metadata
Asked Answered
B

2

3

I have an Ivy project that publishes its artifacts to a Nexus Maven repository. I then need other Maven projects to be able to use those jars as dependencies. I have been able to get Ivy to create and upload the pom.xml along with the jars, which is working fine. The problem is, when I use Ivy to publish a new SNAPSHOT version - none of the Maven projects will retrieve the new snapshot dependency, even if I do:

mvn clean install -U

I have noticed that Ivy does not publish a maven-metadata.xml file to the repos -- I assume that is the problem? If so, are there any ways to get Ivy to produce this?

Blest answered 2/4, 2013 at 18:38 Comment(0)
L
3

Ivy can be configured to read this file when resolving dependencies (see the "m2compatible" attribute of the ibilio resolver), but the publish task does not create or update this file.....

Seemingly it's the client's job to create and update the "maven-metadata.xml" file.... This is an undocumented feature of Maven repositories. (If someone could find where it's described, perhaps an ivy bug could be fixed).

The standard work-around is to periodically schedule a Nexus task to regenerate the metadata files. See:

A more extreme solution is to use the Maven ANT task to perform the publish step....

Commentary on snapshot revisions

In recent times I've come to the conclusion that snapshot releases are not worth the effort. Continuous delivery promotes the concept that each build is potentially releasable and ivy has a nifty buildnumber task which ensures each build is unique. I find my build process is simpler when there is only one kind of build.

Snapshots is a feature only required when sharing development build artifacts with other projects using Maven. IMHO ivy's dynamic revision features are more powerful because they resolve the "latest" revision at build time. See how the deliver task is combined with the makepom task in the following examples:

Lauter answered 3/4, 2013 at 20:13 Comment(1)
The update requirement for the maven-metadata.xml is documented right here: support.sonatype.com/entries/24431666 .Ezara
C
1

I had a similar problem and found the following website helpful in solving it: http://ssinghvi.wordpress.com/2012/01/26/unable-to-retrieve-latest-artifact-from-sonatype-nexus-using-apache-ivy/

Basically use <ibiblio name="Maven Central" m2compatible="true" useMavenMetadata="false" root="http://…" />

Cunnilingus answered 22/5, 2013 at 1:19 Comment(2)
That's great, but this post is about publishing, not resolving artifacts. The documentation states clearly that this attribute is only used to tell the resolver how and where to get the file. Nothing about publishing that I can see (ant.apache.org/ivy/history/latest-milestone/resolver/… ). For those of us who want to use Ivy in a heterogeneous language/build environment -- where we actually rely on maven-metadata.xml -- we are left out in the cold.Ezara
We use Ivy for both publishing and retrieving so this fix was fine for usGilbye

© 2022 - 2024 — McMap. All rights reserved.