ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <>
Subject Re: Don't how ant interacts with directories
Date Wed, 08 Dec 2004 22:06:40 GMT

1.	The value of the "basedir" attribute of <project>
D:\Local\AntExps\directoryExp\build.  The value of
${user.dir} was
D:\Local\AntExps\directoryExp\build.  So how can the
value of ${pwd} be
D:\Local\AntExps\directoryExp which is one level up
from the directory 
I ran ant?

A: You have misunderstood <dirname>.  <dirname> finds
the parent directory of the entity passed it,
regardless of whether that entity is a directory

2.	${source.dir} was supposed to be
${user.dir}../source, which should
have evaluated to
D:\Local\AntExps\directoryExp\source, but instead it
evaluated to D:\Local\AntExps\directoryExp\build..
(note the two 
dots).  Why?

A: The reason you are seeing ".." trailing what you
thought you would see is that you have omitted a
necessary slash before "..".  However, this would
remain part of the filename using the value attribute.
   In general you will see
surely-no-worse-and-probably-better results from
<property>'s "location" attribute instead of "value"
for directory names and the like.  Also, answer this: 
do you want basedir and user.dir tied together? 
basedir is the current directory OF THE BUILDFILE
while user.dir is the USER's current directory.  So
what happens when someone invokes this buildfile from
another directory?  I'm not going to take the time to
figure it out but I'll bet it's not what you intend. 
Most builds don't need to use user.dir for anything.

3.	${build.dir} was supposed to be the same as
${user.dir} and evaluate
to D:\Local\AntExps\directoryExp\build, but instead
evaluated to
D:\Local\AntExps\directoryExp which is one level up
from ${user.dir} in 
directory hierarchy.  How can this happen?

A: See #1

4.	${lib.dir} was supposed to evaluate to
D:\Local\AntExps\directoryExp\build\lib, but instead
evaluated to
D:\Local\AntExps\directoryExp\build, why?

A: See #1

One more thing:  it appears you have a project base
directory, then you want your Ant buildfile to live in
a build directory.  It is more common usage to store
the buildfile in the base directory, hence the
property name "basedir".  In this case it means you
would avoid some of the ".." headache.  For that
matter you could have specified basedir=".." on your
project tag and probably been better off.  You CAN do
it the way you're doing it, but I think it's not a
very common thing to do, unless there is a realy
reason you can't put the buildfile in the base
directory.  Also, when your build directory contains
nothing but artifacts of the build process, it's very
easy to write a "clean" target:

<delete dir="${build.dir}" />


Do you Yahoo!? 
Yahoo! Mail - Find what you need with new enhanced search.

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

View raw message