问题
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?
回答1:
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:
- http://www.sonatype.com/people/2009/09/nexus-scheduled-tasks/
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:
- Convert ivy.xml to pom.xml
- Automate ivy revision increase for all my projects using ant script
回答2:
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://…" />
来源:https://stackoverflow.com/questions/15771776/publishing-ivy-snapshots-with-maven-metadata