ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: changing directories
Date Mon, 19 Mar 2001 12:01:08 GMT
Will Holcomb <will@odin.himinbi.org> wrote:

> The problem I am having is that ant doesn't actually change
> directories when you call another buildfile using an <ant>
> directive. Right?

This is, because you cannot do that in Java at all - without forking
that is. You could invoke Ant with <java>, setting fork to true and
dir to the value you need.

> 
> Here is the scenario:
> 
> 1. /build.xml creates the directories /output, /output/pdf,
>    /output/html, and /output/images 
> 2. /build.xml runs: <style in="doc.xml" destdir="/output/html"
>    out="/output/html/index.html" style="doc-html.xsl"/>
> 3. /build.xml copies build-pdf.xml to /output/pdf/build.xml and
>    then runs: <ant dir="/output/pdf"/>

Why are you using a separate build.xml for step 3?

> With the current <style> tag the destdir tag is ignored when the in
> and out tags are being used

So use paths relative to your project's basedir when defining them. Is
this an option?

> If the destdir is going to be required then it seems like it ought
> to be used in some way instead of silently ignored.

Fair enough - I'll change <style> to make destdir optional if out has
been specified.

> but the simplest solution would be if ant was actually changing
> directories.

Not possible, unless we fork a new VM.

> I think that it is something funny in the user.dir property. I wrote
> a little test program (attached) which checks for a file, changes
> user.dir, and checks again. It just prints the value of the
> filename, File().getAbsulotePath(), and File().exists()

Well, this may or may not work at all. It will get you into serious
troubles if your CLASSPATH contains relative paths, that's for
sure. The VM for MacOS is reported to change directories correctly,
but ...

See the Execute class and all the OS-specific special cases Ant has to
go through, to invoke an external command in a given directory.

Stefan

Mime
View raw message