Installation

There are basically two ways to install Ivy: either manually or automatically.

Manually

Download the version you want here, unpack the downloaded zip file wherever you want, and copy the Ivy jar file into your Ant lib directory (ANT_HOME/lib).

If you use Ant 1.6.0 or superior, you can then simply go to the src/example/hello-ivy dir and run Ant: if the build is successful, you have successfully installed Ivy!

If you use Ant 1.5.1 or superior, you have to modify the build files in the examples:

  • remove the namespace section at their head: xmlns:ivy="antlib:org.apache.ivy.ant"

  • add taskdefs for Ivy tasks:

  <taskdef name="ivy-configure" classname="org.apache.ivy.ant.IvyConfigure"/>
  <taskdef name="ivy-resolve" classname="org.apache.ivy.ant.IvyResolve"/>
  <taskdef name="ivy-retrieve" classname="org.apache.ivy.ant.IvyRetrieve"/>
  <taskdef name="ivy-publish" classname="org.apache.ivy.ant.IvyPublish"/>
  • replace ivy:xxx tasks by ivy-xxx You can now run the build, if it is successful, you have successfully installed Ivy!

If the build is not successful, check the FAQ to see what might be the problem with the ivyrep resolver.

Ivy dependencies

One of the two binary versions of Ivy doesn’t include the optional dependencies. To download them using Ivy, all you need is to run the Ant build file provided in the distribution. This will use Ivy itself to download the dependencies. Then you should see the Ivy optional dependencies in the lib directory, organized per configuration (see the ivy.xml for details about the configurations and their use).

Automatically

If you want to use Ivy only in your Ant build scripts, and have an internet connection when you build, you can download Ivy from this site and use the downloaded version automatically, using this simple build snippet:

<project xmlns:ivy="antlib:org.apache.ivy.ant">
    <property name="ivy.install.version" value="2.5.0"/>
    <condition property="ivy.home" value="${env.IVY_HOME}">
      <isset property="env.IVY_HOME"/>
    </condition>
    <property name="ivy.home" value="${user.home}/.ant"/>
    <property name="ivy.jar.dir" value="${ivy.home}/lib"/>
    <property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar"/>

    <target name="download-ivy" unless="offline">

        <mkdir dir="${ivy.jar.dir}"/>
        <!-- download Ivy from web site so that it can be used even without any special installation -->
        <get src="https://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
             dest="${ivy.jar.file}" usetimestamp="true"/>
    </target>

    <target name="init-ivy" depends="download-ivy">
      <!-- try to load Ivy here from Ivy home, in case the user has not already dropped
              it into Ant's lib dir (note that the latter copy will always take precedence).
              We will not fail as long as local lib dir exists (it may be empty) and
              Ivy is in at least one of Ant's lib dir or the local lib dir. -->
        <path id="ivy.lib.path">
            <fileset dir="${ivy.jar.dir}" includes="*.jar"/>

        </path>
        <taskdef resource="org/apache/ivy/ant/antlib.xml"
                 uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
    </target>
</project>

Then the only thing to do is to add the init-ivy target in the depends attribute of your targets using Ivy, and add the ivy namespace to your build script. See the self contained go-ivy example for details about this.