ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <>
Subject Re: Correct Task Behaviour
Date Tue, 16 Oct 2007 08:43:30 GMT
Matthew Haynes wrote:
> Hello,
> I am the developer of a small ant task
> The task takes file paths as attributes and a recent bug / feature request
> has posed a question. When using a build file located outside of the current
> working directory how should relative paths be handled?
> For example if i execute ant like this:  ant -file webstuff/build.xml
> Should relative paths specified in the build file now become relative to the
> current working directory? Or should they stay relative to the build file?
> Depending on how I handle the paths in the source code both options are
> available.
> What is the usual expected behaviour here?

1. If your task takes anything like a File as an attribute, by the time 
you see it it has already been resolved relative to the basedir

2. this is the convention that nearly everything in Ant supports

3. the sole exception is <import>, which was designed to let you do 
relative, chained <import> operations. Each import is relative to the 
current build file, unless you go <import file="${basedir}/something.xml" />

4. the fact that import works this way causes lots of fun under Eclipse, 
if it copies the build.xml file to its workspace while leaving the rest 
of the project elsewhere in the filesystem.

So, accept File, Path and Fileset datatypes and Ant will do all the work 
for you, and leave your task consistent with everything else.


Steve Loughran        
Author: Ant in Action 

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

View raw message