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.
A
depends on B;[2.0,4.0]
and B;3.1
is later added to the repository.transitive="false"
. Assuming that existing items in the repository do not change, this allows repeatable builds.ResolveEngine
to make the ResolveReport
available, then add a custom DeliverEngine
to use it.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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With