« Circle/Ellipse Paradox... NOT! | Main | Remote Exceptions and the LSP »

Mixing <ant> and <subant> leads to confusion...

Update: It's not a bug, it's a feature! Seriously. ;) It turns out that the <ant> task effectively sets the basedir property as a user-property, which means that it can't be changed. User-properties are propogated through regardless of the inheritAll flag. The doco could have been clearer, but that's life.

The easy work around: don't use the dir attribute to locate the file, actually specify it in full (see the bug report for the example).

----

I lodged a bug report with Apache Ant today; first one in a long while. It turns out the the <ant> and <subant> tasks aren't entirely compatible.

I've got three build files. The first uses <ant> to invoke the second. The second, in turn, uses <subant> to invoke a third (but potentially a heap) build file.

When I use either the third or the second build files directly, it works fine. When I get the first one to invoke it, the basedir for the third script is wrong (it's set to the basedir of the second).

Example transcript:


C:\Temp\subanttest\sub\sub1>ant
Buildfile: build.xml

build:
[echo] sub1 base dir=C:\Temp\subanttest\sub\sub1

BUILD SUCCESSFUL
Total time: 0 seconds
C:\Temp\subanttest\sub\sub1>cd ..

C:\Temp\subanttest\sub>ant
Buildfile: build.xml

build:
[echo] sub base dir=C:\Temp\subanttest\sub

build:
[echo] sub1 base dir=C:\Temp\subanttest\sub\sub1

BUILD SUCCESSFUL
Total time: 1 second
C:\Temp\subanttest\sub>cd ..\main

C:\Temp\subanttest\main>ant
Buildfile: build.xml

build:
[echo] main base dir=C:\Temp\subanttest\main

build:
[echo] sub base dir=C:\Temp\subanttest\sub

build:
[echo] sub1 base dir=C:\Temp\subanttest\sub

BUILD SUCCESSFUL
Total time: 1 second
C:\Temp\subanttest\main>

There's an example script in the bug report if anyone's interested.

Post a comment


About

This page contains a single entry from the blog posted on June 18, 2004 1:05 PM.

The previous post in this blog was Circle/Ellipse Paradox... NOT!.

The next post in this blog is Remote Exceptions and the LSP.

Many more can be found on the main index page or by looking through the archives.

Creative Commons License
This weblog is licensed under a Creative Commons License.
Powered by
Movable Type 3.35