I would like to add dependency to my Ant project; for example I want to add hibernate dependency to my project.
I'm new to Ant. Before I used maven tool to build project.
in maven it is very easy to add dependency to pom.xml
file.
My build.xml file
<?xml version="1.0" encoding="UTF-8"?>
<project name="Demo ANT Project-1" default="run">
<target name="run" depends="compile">
<java classname="com.company.product.RoundTest">
<classpath path="staging"/>
</java>
</target>
<target name="compile">
<javac includeantruntime="false" srcdir="./src" destdir="staging" />
</target>
</project>
I want to add dependency to above Ant xml file.
First of all Ant is older than Maven and therefore does not include core support for dependency management.
Adding ivy
Ivy is a dependency management framework for Ant
http://ant.apache.org/ivy/
To enable it you need to do two things. First include the ivy task namespace to the top of your build file:
A secondly you'll need to install the ivy jar into one of the standard locations that ANT uses for it's 3rd party extensions:
I like to make my builds standalone so include a target that does this for me automatically:
Using ivy
This is a very extensive subject, the following is a simple example to download the hibernate jar and it's dependencies:
Produces the following output:
This ivy managed classpath can then be used in your javac task