Karthik
Karthik

Reputation: 63

ant warning : could not load antlib.xml

I have the antcontrib.jar in my lib folder of Ant. I set my ant home as "C/Prog Files/apache-ant".

But still when I run my build.xml, i get the warning "could not load antlib.xml and antcontrib.prop".

Because of this, I am not able to do any "regex" operations.

I properly loaded the antcontrib.jar in the lib folder of the ant.

Where I am wrong here?

Upvotes: 0

Views: 16961

Answers (2)

Chad Nouis
Chad Nouis

Reputation: 7041

Here's an example of an Ant script that uses Ant-Contrib's <propertyregex> task:

build.xml

<project name="ant-propregex-simple" default="run">
    <taskdef resource="net/sf/antcontrib/antlib.xml" />
    <target name="run">
        <property name="line.to.test" value="First Second" />
        <property name="the.regex" value="^([^ ]*) ([^ ]*)$" />
        <propertyregex 
            input="${line.to.test}" 
            regexp="${the.regex}" 
            select="\2" 
            property="the.match" 
        />
        <echo>${the.match}</echo>
    </target>
</project>

The key is the <taskdef ...> line.

Output

run:
     [echo] Second

BUILD SUCCESSFUL

Upvotes: 0

Laksitha Ranasingha
Laksitha Ranasingha

Reputation: 4507

Provide resource and classpath in your taskdef correctly as follows

<typedef resource="net/sf/antcontrib/antlib.xml" classpath="<path to ant-contrib.jar>"/> 

Upvotes: 3

Related Questions