27

Possible Duplicate:
Ivy fails to resolve a dependancy, unable to find cause

I'm trying to run the following build task (initIvy):

<?xml version="1.0" encoding="UTF-8"?>
<project name="myproject-build" default="package" basedir=".." xmlns:ivy="antlib:org.apache.ivy.ant">
    <property file="build/build.properties"/>
    <property environment="env"/>

    <!-- Ant library path, including all of its plugins. -->
    <path id="ant.lib.path">
        <fileset dir="${env.ANT_HOME}/lib" includes="*.jar"/>
    </path>

    <!-- CONFIGURE IVY -->
        <taskdef resource="org/apache/ivy/ant/antlib.xml"
            uri="antlib:org.apache.ivy.ant" classpathref="ant.lib.path"/>

    <!-- Use Ivy tasks to resolve dependencies into the local Ivy cache. -->
    <target name="initIvy">
        <!-- Initialize Ivy and connect to host repository. -->
        <echo message="Initializing Apache Ivy and connecting to the host repository."/>
        <ivy:settings url="${ivy.std.repo.settings.url}" realm="${ivy.std.repo.realm}" username="${ivy.std.repo.username}" passwd="${ivy.std.repo.password}"/>

        <!-- Clear/flush the Ivy cache. -->
        <echo message="Cleaning the local Ivy cache for the current build."/>
        <ivy:cleancache/>
    </target>

    <!-- Rest of buildfile omitted for brevity. -->

</project>

When I run ant -buildfile build.xml initIvy I get the following output:

Buildfile: /<path-to-my-project>/build/build.xml
    [taskdef] Could not load definitions from resource org/apache/ivy/ant/antlib.xml. It could not be found.

initIvy:
    [echo] Initializing Apache Ivy and connecting to the host repository.

BUILD FAILED
/<path-to-my-project>/build/build.xml:81: Problem: failed to create task or type antlib:org.apache.ivy.ant:settings
    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:
    -/<path-to-my-ANT_HOME>/lib
    -/home/myUser/.ant/lib
    -a directory added on the command line with the -lib argument

When I go to ${ANT_HOME}/lib, I don't see any JARs labeled "antlib*.jar".

So I'm guessing I downloaded a version of Ant that did not include Antlib, and now that I'm using Ivy (which uses Antlib), the build is choking?

If this is an Antlib issue, then I believe I want one of the distros available here. If so, can someone confirm which one I should use (that only contains Antlib and not anything else), and confirm the process for installing it; i.e., is it just as simple as putting the correct JAR in ${ANT_HOME}/lib? Etc.

If this is an Ivy issue, then can someone point me in the right direction as to what could be going on?

And if this is neither Antlib nor Ivy, ditto for the question directly above. Thanks in advance!

Community
  • 1
  • 1
IAmYourFaja
  • 55,468
  • 181
  • 466
  • 756

1 Answers1

68

I think you might be missing Apache IVY library. Download it from here - apache ivy Copy the jar in your ant lib directory.

For example (change version numbers as appropriate):

  1. Download and install Ant (e.g., C:\Apps\Tools\apache-ant-1.9.7).
  2. Download and extract Ivy (e.g., C:\Users\UserName\Downloads\apache-ivy-2.4.0)
  3. Copy C:\Users\UserName\Downloads\apache-ivy-2.4.0\ivy-2.4.0.jar into C:\Apps\Tools\apache-ant-1.9.7\lib.

Ant is configured to use Ivy.

Dave Jarvis
  • 30,436
  • 41
  • 178
  • 315
Shwetanka
  • 4,976
  • 11
  • 44
  • 68
  • 1
    Dang - that was it. I had just copied the Ivy lib JAR, forgetting to copy the Ivy JAR. Just out of curiosity, what was it that gave you the (right) idea? Just trying to learn so next time I can diagnose the problem myself! Thanks again! – IAmYourFaja Oct 01 '12 at 17:26
  • 3
    @4herpsand7derpsago [antlib](https://ant.apache.org/manual/Types/antlib.html) is a generic term in ant and not a separate tool. If you get "Could not load definitions from resource org/apache/ivy/ant/antlib.xml. It could not be found" " then it means means, that there is no jar file in the classpath, which contains and "org/apache/ivy/ant/antlib.xml". And because this file is part of the ivy.xml you know that the lib is missing. – oers Oct 02 '12 at 07:13
  • 5
    A more convinient way is to use the [Ivy Eclipse Update Site](http://www.apache.org/dist/ant/ivyde/updatesite) - Install both "Apache Ivy"-Libs (Apache Ivy and Apache Ivy Ant Taks) – teclis Jan 09 '15 at 10:24
  • 2
    "your ant lib directory" is " ANT_HOME/lib and a user specific directory, ${user.home}/.ant/lib. " if you're not familiar with ant (just like me) – Yugang Zhou Jan 09 '15 at 13:22
  • I had the same problem but and still wouldn't budge. Eventually I needed to add the ivy.jar to the class path of the ant run configuration. That fixed it. – realtimez Feb 16 '15 at 22:26
  • On mac i had to put the file @ /usr/local/Cellar/ant/1.10.1/libexec/lib – user93796 May 22 '17 at 18:20
  • 1
    I had the same problem in ubuntu 18 --Install ant $sudo apt update $sudo apt install ant --Download the ivy from http://ant.apache.org/ivy/download.cgi I used the git method $git clone https://git-wip-us.apache.org/repos/asf/ant-ivy.git $ant jar You can find ivy.jar in --ant-ivy/build/artifact/jars Do $cd /usr/share/ant/lib $sudo ln -s path_to_ivy_jar And you are good to go – Ayush Chaurasia Feb 26 '21 at 12:34