0

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

Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
Kevin K
  • 408
  • 2
  • 18
  • I have continued to do research and it appears that I should use `Triggers` to resolve my issue. I'll update once I get it working. Further suggestions/tips are welcome. – Kevin K Feb 06 '17 at 21:08

1 Answers1

0

If you have dependencies on files located within archives, perhaps you should investigate the packager resolver in ivy.

This resolver is designed to download + extract archives and then use an ANT snippet to decide which files within you want to depend on. At first glance complicated, but once understood very powerful.

The following example shows how to depend on a jar, contained inside a downloadable ".tar.gz" archive:

Community
  • 1
  • 1
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185