Ivy fails to resolve a dependency, unable to find cause

ANT cannot find the ivy jar. Needs to be downloaded, extracted, and the ivy-x.y.z.jar placed into one of the following locations:

  • $ANT_HOME/lib
  • $HOME/.ant/lib

Enabling ivy

Ivy is packaged as an antlib, so to enable it you need to do the following

1)
Declare the ivy namespace at the top of the build file

<project ..... xmlns:ivy="antlib:org.apache.ivy.ant">

2)
Include the ivy jar in one of the ant library directories

Your error message indictates some of the possible locations for antlibs:

This appears to be an antlib declaration. 
Action: Check that the implementing library exists in one of:
        -C:\Users\Simon\eclipse\plugins\org.apache.ant_1.8.2.v20120109-1030\lib
        -C:\Users\Simon\.ant\lib
        -a directory added on the command line with the -lib argument

Note:

The beauty of an antlib is that you don’t need to perform the taskdef (It’s optional if you want to place the ivy jar in a non-standard location)

How to bootstrap a build

Even though ivy is an ANT sub-project, for some inexplicable reason ivy is not packaged with ANT….

I normally include the following target in my build files to setup a new environment:

<target name="bootstrap" description="Used to install the ivy task jar">
    <mkdir dir="${user.home}/.ant/lib"/>
    <get dest="${user.home}/.ant/lib/ivy.jar" src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.2.0/ivy-2.2.0.jar"/>
</target>

It downloads the ivy jar from Maven Central.

Since all other ANT tasks can subsequently be downloaded using ivy, few people object to this little piece of ugliness at the top of the build file.

Leave a Comment