ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Cryder <christi...@granitepeaks.com>
Subject Question about Basedir
Date Tue, 22 Jun 2004 05:02:47 GMT
Hi folks, I have a question about the Ant basedir attribute (I'm using
Ant 1.6 Alpha, I think). Here's what I'm trying to do.

Let's say I'm working with a simple little build structure, and I
have the following in WEB-INF/bin/build.xml:

     <target name="foo88">
         <mkdir dir="./foo88" />
     </target>
     <target name="foo99">
         <taskdef name="events"
classname="org.enhydra.barracuda.taskdefs.EventBuilder"
classpathref="build.classpath" />
         <events sourceout="./foo99"
descriptor="${build.dir}/event-hierarchy.xml" />
     </target>

(EventBuilder is a custom taskdef which internally creates a dir by
doing something like this:

     String targetPackage = cs.eventPackage.replace('.','/');
     File targetPath = new File(sourceOutDir+"/"+targetPackage);
     if (!targetPath.exists()) {
         if (!targetPath.mkdirs()) throw new BuildException("Error
creating path: "+targetPath, getLocation());
     }

Now, if I execute these targets (foo88, foo99) from the bin directory,
foo88 and foo99 dirs will be created _beneath_ bin, as expected.

Now, let's say I create another build.xml file one level up in WEB-INF,
which invokes these tasks like this:

     <target name="foo88">
         <ant dir="./bin" target="foo88" inheritAll="false" />
     </target>
     <target name="foo99">
         <ant dir="./bin" target="foo99" inheritAll="false" />
     </target>

What I am saying here is set the working directory to /bin, and then
execute the tasks. So what _should_ happen is what happened above - the
foo88 and foo99 dirs should again be created below /bin. But they don't.
  Or at least not entirely.

foo88 DOES get created below /bin. foo99 however, gets created one
directory up from that, below WEB-INF. What this means is that the call
to foo99 target is not getting the basedir reset, or (more likely) that
the custom EventBuilder taskdef is not taking the basedir into account
properly.

And that's what I'm trying to understand. Looking at the src for Mkdir,
it looks completely straightforward - <mkdir dir="./foo88" /> seems to
automatically take account of the "current" base dir. There's nothing
special in the source to check for current dir of anything like that.

And yet when EventBuilder does the same thing, it always seems to create
the target events directory relative to the _initial_ build.xml, NOT the
  newly specified basedir.

SO, what do I need to do to have EventBuilder function the same way, to
correctly take account of the "working dir" rather than the basedir of
the build.xml that kicked the whole thing off?

That make sense?

tia,
Christian
----------------------------------------------
Christian Cryder
Internet Architect, ATMReports.com
Project Chair, BarracudaMVC - http://barracudamvc.org
----------------------------------------------
"Coffee? I could quit anytime, just not today"





-- 

Christian

----------------------------------------------
Christian Cryder
Internet Architect, ATMReports.com
Project Chair, BarracudaMVC - http://barracudamvc.org
----------------------------------------------
"Coffee? I could quit anytime, just not today"

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message