Linux – How to get Apache Ant to recognize Ivy

antinstallationlinux

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

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

retrieve-all:

BUILD FAILED
/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:
        -/usr/share/ant/lib
        -/home/ec2-user/.ant/lib
        -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")

Best Answer

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.

Related Question