ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antoine Lévy-Lambert <>
Subject Re: calling another build file, changing directory
Date Mon, 23 Feb 2004 19:44:56 GMT
Mark Lybarger wrote:

>i have two ant scripts, one which calls the other.  the problem is that in build.test.xml,
it's using a property of basedir = ".".  this doesn't work out so nicely if the user isn't
"in" the folder the build.test.xml is in.  is there a way to cd into a folder or somesuch
with the ant call?
Hi Mark,

The principle is that ant's default basedir is the directory where the 
build.xml file which you are executing resides.

basedir="." is a way of explicitly confirming this default setting.

*There is no cd task in ant.*

To get a full path out of a relative path, if you need this, you can use 
the construct
<property name="foo.dir" location="foo/bar"/>
if you do this and the basedir of your build file is in /home/mark, then 
the foo.dir will be resolved to /home/mark/foo/bar

Most of the file attributes, are declared in the Java source code of ant 
of type file and resolve relative to the base dir of the build file they 
are in.

Unfortunately, the ant task has a String argument for the setAntfile 
method. Because of this, resolving with
<property name="test.file.path" location="build.test.xml"/> the location 
of your build file will help you.

I wonder whether other committers would consider this behavior a bug, 
and would be willing to add a new method  Ant#setAntfile(File antfile) 
The effect would be to solve this issue for everyone, while leaving API 
users happy of still being able to call setAntfile(String file)



>  <target name="test" description="run cactus tests">
>    <ant antfile="${test.file.path}" target="${}">
>      <property name="buildProps" value="${}" />
>      <property file="" />
>    </ant>
>  </target>

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message