7
votes

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...

1
Do you get an error message with a specific task? If so can you post that part of the buildfile? - martin clayton
I am sure if basedir path is set correctly everything will work fine. But the thing is ../is not working in basedir. Can you tell if i use .. instead of ../ is it correct ! - Ashwin Hegde
What do you mean with "Its not working for me", what is the error? How do you call ant from which working directory? - Arne Burmeister
The error was net/sf/antcontrib/antcontrib.properties not found. I am using antcontrib.jar file. Thanks for your help. Its working now. I made few changes in my path. I did ../../ in basedir path. - Ashwin Hegde
Setting ".." in basedir is working. You must tell us what is your error. - Julien Bodin

1 Answers

1
votes

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>