Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ivy - output the results of a resolve to an ivy file

Having resolved my ivy.xml file, I'd like to create a new resolved-ivy.xml file consisting of all of the transitive dependencies found in the resolve. Is it possible to do this?

This is different to a deliver, which (I believe) only writes out the immediate dependencies from your ivy.xml, not the transitive dependencies. The deliver Ant task does have a delivertarget attribute, which looks in the documentation like it should do this. In practice it works only for modules in the same organisation (so not generally for all dependencies) and generates a file per module.

It's also different from the ivy-report XML file that is generated during the resolve, but not hugely different. If what I'm trying is not possible then I'll just hack at this file directly, I suppose.

The context here is trying to enable repeatable reproducible builds, including in the presence of changes (new libraries, versions) to the repository. There are posts around the interwebs that try to do this, and none I've found can do it properly.

  • Additions to the Ivy repository can change resolve results, in particular if any dependencies anywhere in the repository (not just your project) have range dependencies. Example: A depends on B;[2.0,4.0] and B;3.1 is later added to the repository.
  • Idea is to resolve as normal, write the resolve as a flattened Ivy file, save that in your project's VCS for that tag (or whatever) and subsequently resolve against that file with transitive="false". Assuming that existing items in the repository do not change, this allows repeatable builds.
  • If anyone has any better ideas for doing this, I'm all ears. At the moment I'm expecting to have to hack some combination of the ResolveEngine to make the ResolveReport available, then add a custom DeliverEngine to use it.
like image 529
Joe Kearney Avatar asked May 04 '12 07:05

Joe Kearney


2 Answers

artifactreport> might help.

Use the deliver task to create an ivy.xml with the dynamic version constraints replaced by the static version constraint (i.e [2.0,3.0[ becomes 2.2.1):

<ivy:deliver conf="*(public)" deliverpattern="${dist.dir}/ivy.xml"/>

Then use the resolve task on that file to prepare for artifactreport.

<ivy:resolve file="${dist.dir}/ivy.xml"
             conf="*(public)"
             refresh="true"
             type="ivy" />

Finally, artifactreport will do the transient dependency resolution.

<ivy:artifactreport tofile="${dist.dir}/artifactreport.xml" />

artifactreport.xml will look like

<modules>
<module organisation="com.googlecode.flyway" name="flyway" rev="1.7" status="release"/>
<module organisation="org.postgresql" name="postgresql-jdbc" rev="9.0" status="release"/>
<module organisation="org.hibernate" name="hibernate" rev="3.3.2" status="release"/>
<module organisation="org.apache.commons" name="commons-daemon" rev="1.0.2" status="release"/>
...

Use XSLT to produce the ivy.xml form.

like image 102
Martin Avatar answered Sep 29 '22 16:09

Martin


The feature you are looking for was added in Ivy 2.4: fixdeps. It reads an ivy.xml file, which in this case serves as an specification, and output an equivalent file, e.g. ivy-resolved.xml, with all transitive dependencies resolved.

like image 39
Pcgomes Avatar answered Sep 29 '22 16:09

Pcgomes