1 Ant Task
The main and most frequent way to use Ivy is in the ant build file. However, Ivy can also be invoked as an independent application.
If you use the ant version 1.6.0 or higher, you just need to add the Ivy namespace to your project (the attributes of your project tag)
Xmlns:ivy= "Antlib:org.apache.ivy.ant"
So you can invoke the Ivy task.
If you want your build processing Ivy.jar, whether it's in Ant's Lib directory or in the local Lib directory. You can use a task definition like this
<path id="ivy.lib.path">
<fileset dir="path/to/dir/with/ivy/jar" includes="*.jar"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
Combined with the ANTLIB definition in the project namespace, it will load the Ivy class from your ant class library or your local directory (try Path/to/dir/with/ivy/jar in this example).
If you use ant1.5.1 or higher, you have to define the tasks you use in your build files. For example:
<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-deliver" classname="org.apache.ivy.ant.IvyDeliver"/>
<taskdef name="ivy-publish" classname="org.apache.ivy.ant.IvyPublish"/>
Note: The tasks listed above are not exhaustive. For a complete list of tasks with the corresponding class, check out the antlib.xml in SVN or the version you are using
Then you can use the tasks, but check their names, the following example assumes that you use the Ivy namespace (ivy:xxx Task), but for ant1.5 you cannot use namespaces, and if you want to follow the task definition above you can use ivy-xxx tasks.
If you use an ant version below 1.5.1, you can't use the Ivy task ... You should call Ivy as an external program.
2 call Ivy from ant: Start step
Once your build file can invoke the Ivy task, the simplest task of using Ivy is to invoke the Ivy retrieve task without any parameters.
<ivy:retrieve/>
This will call Ivy using the default value, which is feasible in many projects. In fact, it is equivalent to
<target name="resolve">
<ivy:configure />
<ivy:resolve file="${ivy.dep.file}" conf="${ivy.configurations}" />
<ivy:retrieve pattern="${ivy.retrieve.pattern}" conf="${ivy.configurations}" />
</target>