ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Sitsky <s...@users.sourceforge.net>
Subject [PATCH] basedir for child project not set correctly from <ant> task
Date Fri, 19 Oct 2001 15:45:48 GMT



I believe I have stumbled across a bug in ant (1.3 + 1.4.1).  Assume the 
following build file in ~/TEST:

<project name="tester" default="zot" basedir=".">
    <target name="zot">
         <ant dir="${basedir}/zotdir" target="jar"/>
    </target>
</project>

and the following build file in ~/TEST/zotdir:

<project name="anothername" default="jar" basedir="..">
    <target name="jar">
         <echo message="${basedir}"/>
    </target>
</project>

If in the ~/TEST directory I call "ant", I would have expected the echo to 
have printed ~/TEST, but it prints ~/TEST/zotdir, regardless of the setting 
of basedir in ~/TEST/zotdir/build.xml.

However, if I do:

cd ~/TEST/zotdir
ant

then the echo message prints out the correct result.

I have attached a patch which fixes the problem.  

The main change is in ProjectHelper, where the basedir of a project can only 
be overwritten if it is a user property (set on the command line) rather than 
just a property.  This is where the bug was, since in the execute method for 
the Ant class, newProject.setBaseDir(dir) is called, which sets the basedir 
property to the directory that the build file is located in.

The following line:

newProject.setUserProperty("basedir" , dir.getAbsolutePath());

was removed, since the basedir property is already set as a side effect of 
the previous line, and as far as I can tell, it should be a system property, 
not a user property.

I have only just started to look at the ant sources, so I may have made a 
bad assumption somewhere...

Any comments?

Cheers,
David

Mime
View raw message