Getting an error "Could not load definitions from resource net/sf/antcontrib/antcontrib.properties. It could not be found."
Asked Answered
E

6

23

I am getting an error Could not load definitions from resource net/sf/antcontrib/antcontrib.properties. It could not be found. when I am trying to ant build on eclipse. So I downloaded ant-contrib-0.6.jar and kept it in my /lib location of apache ant, but it still does not resolve my issue. I have also tried by specifying the /lib location in my CLASSPATH system variable. How can I get around this error?

Esau answered 8/3, 2013 at 23:6 Comment(1)
I don't know about Eclipse, but in NetBeans it installs an Ant too. But you can set which installation of Ant to use. Did you put the lib in the correct Ant installation?Peal
J
33

You can provide full path to the ant-contrib JAR explicitly using "classpath" element:

<taskdef resource="net/sf/antcontrib/antlib.xml">
  <classpath>
    <pathelement location="${path-to-ant-contrib}/ant-contrib-1.0b3.jar"/>
  </classpath>
</taskdef>

EDIT: Link contributed by Djacomo:

Justinejustinian answered 11/3, 2013 at 9:20 Comment(3)
Put your ant-contrib-*.jar into $HOME/.ant/lib and restart Eclipse. This works also on Windows.Justinejustinian
<not_relevant_for_eclipse_but_matches_the_question_title>This does not help, since setting the correct env var ANT_HOME is also vital. However I receive this error without eclipse, in the pure ant.</not_relevant_for_eclipse_but_matches_the_question_title>Defeasance
Useful link: ant-contrib.sourceforge.netCanute
D
8

One important thing missing from this StackOverflow page is that setting the correct ANT_HOME env var is absolutely vital and important, without this setting ant keeps telling the same error, regardless of where you copy the ant-contrib-1.0b3.jar on your file systems. This missing thing has costed me a few hours. =)

However I receive this error without eclipse, in the pure ant.

Defeasance answered 25/1, 2015 at 15:54 Comment(1)
Yes, Eclipse configured it for you. By the way, if you download apache-ant, extract it and run bin\ant.bat or bin/ant, ANT_HOME will be set automatically.Justinejustinian
H
7

I fixed that this way:

Add the JAR to the Ant runtime classpath entries.

Window>Preferences>Ant>Runtime>Classpath

Add the JAR to either Ant Home Entries or Global Entries.

Highway answered 11/1, 2018 at 15:3 Comment(0)
S
2

It would appear that you haven't installed the ant contrib jar into the correct lib directory. This can be difficult to do if you have several installations of ANT.

My suggestion is to install your ANT plugins into the "$HOME/.ant/lib" directory. You could go one step further and automate the process as follows:

<project name="ant-contrib-tasks" default="all">

    <taskdef resource="net/sf/antcontrib/antlib.xml"/>

    <target name="bootstrap">
        <mkdir dir="${user.home}/.ant/lib"/>
        <get dest="${user.home}/.ant/lib/ant-contrib.jar" src="http://search.maven.org/remotecontent?filepath=ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar"/>
    </target>

    <target name="all">
        <for param="file">
            <fileset dir="." includes="*.txt"/>
            <sequential>
                <echo message="Found file @{file}"/>
            </sequential>
        </for>
    </target>

</project>
Staffer answered 9/3, 2013 at 7:32 Comment(0)
R
1

Use the below mentioned code in your build xml:

<path id="ant.classpath">
<pathelement location="${ant.jarPath}/ant.jar" />
<pathelement location="${ant.jarPath}/ant-contrib-0.3.jar" />
</path>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
 <classpath refid="ant.classpath" />
</taskdef>

And in your build property file:

ant.jarPath=D:/antjars

And place ant.jar and ant-contrib-0.3.jar in directory:D:/antjars

Rectilinear answered 16/9, 2013 at 10:34 Comment(0)
A
0

Check you have read permissions for the ant-contrib jar file.

In our case after copying the file with another user it did not, giving the same error message.

Auburta answered 30/1, 2017 at 16:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.