Apache Ivy can be found here. Place the Ivy jar file (e.g. ivy-2.4.0-rc1.jar) in the lib directory where ant is installed.

The ivysettings.xml and ivy.xml files need to be in the same location as the related ant build.xml file.

Example contents:

ivysettings.xml:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<ivysettings>
    <settings defaultResolver="simple" />
    <resolvers>
        <chain name="simple">
            <ibiblio name="ibiblio"  m2compatible="true" />
        </chain>
    </resolvers>
    <modules>
    </modules>
</ivysettings>

ivy.xml (partial, just as an example):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<ivy-module version="2.0">

    <info organisation="org.mymodule" module="mymodule"/>

    <dependencies>

        <dependency org="commons-dbutils" name="commons-dbutils" rev="1.7" />
        <dependency org="commons-codec" name="commons-codec" rev="1.11" />

        <dependency org="org.glassfish.jersey.containers" name="jersey-container-servlet" rev="2.22.4" >
            <!-- Part of Tomcat already: -->
            <exclude org="javax.servlet" name="javax.servlet-api" />
        </dependency>

        <!-- Java Spark with Thymeleaf template engine. Note that the spark-core JAR has
             to live in the webapp's WEB-INF/lib directory, not the Catalina base lib.   -->
        <dependency org="com.sparkjava" name="spark-core" rev="2.7.2" >
            <exclude org="org.eclipse.jetty" />
            <exclude org="org.eclipse.jetty.websocket" />
            <!-- Part of Tomcat already: -->
            <exclude org="javax.servlet" name="servlet-api" />
        </dependency>
        <dependency org="com.sparkjava" name="spark-template-thymeleaf" rev="2.7.1" />

        <dependency org="mysql" name="mysql-connector-java" rev="8.0.11" />

        <dependency org="org.slf4j" name="slf4j-simple" rev="1.7.25" />

        <!-- Exclude all javadocs and sources: -->
        <exclude org="*" ext="*" type="source"  />
        <exclude org="*" ext="*" type="javadoc" />

    </dependencies>

</ivy-module>

build.xml needs to include the Ivy namespace:

1
2
<project name="${projectName}" basedir="./" default="build"
         xmlns:ivy="antlib:org.apache.ivy.ant" >

Here is an example of an ant target to clean the Ivy cache:

1
2
3
4
5
<target name="clean-ivy-cache" description="cleans the ivy cache">
    <!-- Run this target if you want to re-fetch all lib JARs.  -->
    <!-- The cache on Linux is here by default "~/.ivy2/cache/  -->
    <ivy:cleancache />
</target>