I have an Ant/Ivy build process that I am trying to improve. I need to resolve dependencies and then extract them to a particular folder.
The dependencies resolve to a $(build_root)/dependency/downloads/[configuration]/[artifactId]/[version]/
location and this works fine. I end up with a .pom
and a .tar.bz2
file in that location.
What I would like to do is have a bit more control over the extraction of the dependency's .tar.bz2
to a directory. We're basically trying to prevent conflicts for a dependency's lib
and inc
by controlling how and where the extraction of the .tar.bz2
output occurs.
We currently do this by resolving all the dependencies, and then having a target to expand the archives blindly.
Our resolve step looks like:
<target name="resolve">
<ivy:retrieve pattern="${dependency.dir}/[conf]/[artifact]/[artifact]-[revision].[ext]" conf="*" />
<condition property="archive.dir.present">
<resourceexists>
<file file="${dependency.dir}"/>
</resourceexists>
</condition>
<antcall if:set="archive.dir.present" target="expand-archives"/>
</target>
Note the separate call to the "expand-archives" target, which looks like:
<target name="expand-archives" description="Expand your Dependency Archives!">
<for param="file">
<path>
<fileset dir="${dependency.dir}" includes="**/*.tar.bz2"/>
</path>
<sequential>
<bunzip2 src="@{file}" dest="${dependency.dir}" />
</sequential>
</for>
<!-- Follow the bunzip2 by the tar command to extract the tarball -->
<for param="file">
<path>
<fileset dir="${dependency.dir}" includes="**/*.tar"/>
</path>
<sequential>
<echo message="Processing: @{file}"/>
<exec executable="tar" failonerror="true">
<arg value="-C"/>
<arg value="${dependency.dir}"/>
<arg value="-xvf"/>
<arg value="@{file}"/>
</exec>
</sequential>
</for>
</target>
What I would love to have is the dest="${dependency.dir}
have a dependency's artifactID appended to it.
Is there any way to get the [artifact]
information from the retrieve and pass that into the expand-archives
target?
Thank you