Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Basedir issue in Ant code

Tags:

ant

I am working on some project using Apache Ant and my project layout is as follows:

project/build.xml
project/properties/build.properties
project/tool/antcontrib.jar 

Here, when i run ant command it working fine and my base directory is basedir="."

Now, I want my project layout to be as follows:

project/folder/build.xml
project/properties/build.properties
project/tool/antcontrib.jar 

Now, I changed my base directory to basedir="..". I thought it might work. but still it's not working. So i wan't to known what we have to set our basedir for '../' Here is the code block related to taskdef defined in my build.xml file.

<taskdef resource="net/sf/antcontrib/antlib.xml">
        <classpath>
            <pathelement location="${tool.ant.contrib}"/>
        </classpath>
    </taskdef>

NOTE: I known that build.xml and properties file should be in same folder its a standard practice. But i don't want to follow that..can any one help me out here...

like image 514
Ashwin Hegde Avatar asked May 16 '13 05:05

Ashwin Hegde


1 Answers

In order to work, the property tool.ant.contrib should be a relative path, not an absolute one.

For instance, this piece of build works:

<project basedir="..">
    <property name="tool.ant.contrib" location="tool/antcontrib.jar" />
    <taskdef resource="net/sf/antcontrib/antlib.xml">
        <classpath>
            <pathelement location="${tool.ant.contrib}"/>
        </classpath>
    </taskdef>
    <if><isset property="tool.ant.contrib" />
        <then><echo message="OK" /></then>
    </if>
</project>
like image 180
Nicolas Lalevée Avatar answered Oct 21 '22 05:10

Nicolas Lalevée