I'm trying to install Apache Ivy, but I can't get ant to recognize it.

Per Apache Ivy installation instructions, I downloaded Ivy from osuosl.org Ivy archives, unpacked it, and copied the .jar file to where ant should be able to see it. However, any ivy-dependent build I attempt fails as follows:

$ ant
Buildfile: /home/ec2-user/ivy/apache-ivy-2.3.0/build.xml

  [taskdef] Could not load definitions from resource org/apache/ivy/ant/antlib.xml. It could not be found.


/home/ec2-user/ivy/apache-ivy-2.3.0/build.xml:55: Problem: failed to create task or type antlib:org.apache.ivy.ant:retrieve
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
No types or tasks have been defined in this namespace yet

This appears to be an antlib declaration. 
Action: Check that the implementing library exists in one of:
        -a directory added on the command line with the -lib argument

I've hunted around, and every page I look at seems to agree that I just need to "install the Ivy jar file", but this doesn't seem to help. I've tried:

  • Copying ivy-2.3.0.jar into /usr/share/ant/lib and/or ~/.ant/lib
  • The same, but renaming it ivy.jar
  • Adding -lib /path/to/ivy-2.3.0.jar to the ant command
  • All of this in the ivy directory or the src/example/hello-ivy directory

Interestingly, in the src/example/go-ivy directory, executing ant succeeds; but that doesn't help other ivy-based builds to run.

I must be missing something excruciatingly obvious, but I can't see what it is. Any ideas?

(This is on "Amazon Linux AMI release 2013.09")


I wound up asking the same question on the Ivy users list, and got a response: http://mail-archives.apache.org/mod_mbox/ant-ivy-user/201402.mbox/%3C52FCAF1B.40903%40reast.net%3E. It turns out I simply needed to execute the following command before invoking ant:

export ANT_HOME=/usr/share/ant/

It appears that, while ant suggests placing files in /usr/share/ant/lib, it won't actually look there unless you set ANT_HOME.

| improve this answer | |
  • +1 You helped at least one person. It won't even look in ~/.ant/lib if this isn't defined. – user606723 Jul 8 '14 at 20:58

I have answered this question on Stackoverflow:

ivy fails to resolve a dependancy unable to find cause. I am including it inline below:

ANT cannot find the ivy jar. Needs to be 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:
        -a directory added on the command line with the -lib argument


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"/>

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.

| improve this answer | |
  • Thanks. I'd seen this answer, and it does describe the exact error message I'm getting, but the suggested fixes don't seem to help. Regarding (1), I'm even seeing this problem with Ivy sample projects such as apache-ivy-2.3.0/src/example/hello-ivy. The build.xml file for this sample project does contain the xmlns:ivy declaration. Regarding (2), I have tried everything I can think of to include the ivy jar, as described in my question. Do you have any further suggestions for determining why Ant is not recognizing the jar file? – Steve Jan 13 '14 at 1:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.