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:Tempsubanttestsubsub1>ant
Buildfile: build.xmlbuild:
[echo] sub1 base dir=C:Tempsubanttestsubsub1BUILD SUCCESSFUL
Total time: 0 seconds
C:Tempsubanttestsubsub1>cd ..C:Tempsubanttestsub>ant
Buildfile: build.xmlbuild:
[echo] sub base dir=C:Tempsubanttestsubbuild:
[echo] sub1 base dir=C:Tempsubanttestsubsub1BUILD SUCCESSFUL
Total time: 1 second
C:Tempsubanttestsub>cd ..mainC:Tempsubanttestmain>ant
Buildfile: build.xmlbuild:
[echo] main base dir=C:Tempsubanttestmainbuild:
[echo] sub base dir=C:Tempsubanttestsubbuild:
[echo] sub1 base dir=C:TempsubanttestsubBUILD SUCCESSFUL
Total time: 1 second
C:Tempsubanttestmain>
There’s an example script in the bug report if anyone’s interested.