Matthew Haynes wrote:
Hello,
I am the developer of a small ant task
http://code.google.com/p/jsmin-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
--
Steve Loughran http://www.1060.org/blogxter/publish/5
Author: Ant in Action http://antbook.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]