ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Barclay <>
Subject handling absolute pathnames better
Date Mon, 14 May 2001 18:40:56 GMT
Will the re-design of Ant address the issue of supporting absolute file 
pathnames better?

I've been running into a number of tasks and options that don't work
well or at all with absolute pathnames.

(Just to clarify, I don't mean a hard-coded absolute pathname, but an
absolute pathname that is built up from a base directory plus a relative 
part and then is stored as a property value.)

Some tasks take filenames directly, and seem to work fine with absolute 
pathnames (e.g., "<copy file='...' ...>").

However, many tasks take only fileset-based elements.  Filesets don't
seem to handle absolute pathnames mixed in with file patterns.  They
also don't seem to handle Windows absolute pathnames.

To use a fileset element to specify a particular file, you have to break 
the absolute file pathname into the pathname of some parent or ancestor 
directory containing the file and a relative pathname from that directory 
to the file.

Notice how having to break the name apart causes problems with using
properties and property references to refer to files.

Consider a multi-module project.  Because a file defined in one module
might be referred to by another module, you might want to define a 
property whose value is a name for the file.  Because the name it
referenced in different modules, you probably can't use a relative

You define an absolute name based on the project root directory plus
the pathname within the project directory (e.g.:

   <property name="file1" value="${sys.rootdir}/mod1/somefile" />

(where sys.rootdir is the root directory of the project, set to "." in 
the root's build file and to ".." in each module's build file (assuming
one directory down)).

The absolute pathname property typically works fine as a task output  
(e.g., "<copy tofile='%${file1}' ... />").

However, it doesn't doesn't usually work so well as an input.  

Many tasks require their input files to be specified as file sets.
File sets need a directory.

An absolute pathname given literally can be split into a directory plus
a relative pathname, but that doesn't work well for properties.  You 
would have to have multiple properties just to name that one file.

Reportedly, using a base directory of "/" lets absolute pathnames work 
as file patterns on Unix (although I don't know if you'd get an extra
slash).  However, that doesn't work for Windows absolute pathnames like "C:\aaa\bbb\ccc".

Please consider making Ant work better with absolute pathnames.

Maybe file patterns should try to evaluate a given string as an 
absolute pathname (so absolute pathnames can be mixed in with patterns).

Maybe fileset elements should have additional attributes to take absolute 
file pathnames separately from relative file patterns (also to avoid 
requiring separate fileset elements for absolute pathnames).

Maybe only improved handling of Windows absolute pathnames is needed.

Daniel Barclay
Digital Focus

View raw message