1

I am using Ant to build my project and Ivy to resolve its dependencies. My project has a dependency which publishes snapshots to my internal Artifactory server.

If the dependency has released a new snapshot, and I do an <ivy:retrieve />, Ivy gets the new snapshot but keeps the previous snapshot around. So I have two versions of the dependency in my lib directory.

The dependency snapshots are named like depproject-1.0.0+23.jar where 23 is the build number. It is published at an address like http://artifactory.example.com/example-snapshots-local/com.example/depproject/1.0-SNAPSHOT/depproject-1.0.0+23.jar. This is not a Maven repository, and it is configured to store unique snapshots.

I am new to Ivy. Is this the expected behavior? How can I configure Ivy or Ant so that only the latest dependency snapshot is kept?

ivysettings.xml

<?xml version="1.0" encoding="UTF-8"?>
<ivy-settings>
    <settings defaultResolver="main" />
    <resolvers>
        <chain name="main">
            <ibiblio
                name="artifactory-example-snapshots"
                m2compatible="false"
                root="http://artifactory.example.com/example-snapshots-local/"
                pattern="[organization]/[module]/1.0-SNAPSHOT/[artifact]-[revision](-[classifier]).[ext]" />
            <!-- more repos listed -->
        </chain>
    </resolvers>
</ivy-settings>

ivy.xml

<ivy-module version="2.0">
    <info organisation="com.example" module="myproject" />
    <dependencies>
        <dependency org="com.example" name="depproject" rev="latest.integration" />
    </dependencies>
</ivy-module>
sourcenouveau
  • 29,356
  • 35
  • 146
  • 243

1 Answers1

1

I'm assuming you're using jars in the lib directory to create a classpath, something like:

<path id="compile.path">
  <fileset dir="lib" includes="*.jar"/>
</path>

Your issue being multiple jars containing the same classes?

I think you have two options:

  1. Use the ivy cachepath task to manage the build classpaths
  2. Purge the lib directory, using he retrieve task to repopulate with the latest jars

The first option may appear more complicated, but it is actually a very powerful way to use ivy. For an example see:

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