Mixing and 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:Tempsubanttestsubsub1>ant
Buildfile: build.xml

build:
[echo] sub1 base dir=C:Tempsubanttestsubsub1

BUILD SUCCESSFUL
Total time: 0 seconds
C:Tempsubanttestsubsub1>cd ..

C:Tempsubanttestsub>ant
Buildfile: build.xml

build:
[echo] sub base dir=C:Tempsubanttestsub

build:
[echo] sub1 base dir=C:Tempsubanttestsubsub1

BUILD SUCCESSFUL
Total time: 1 second
C:Tempsubanttestsub>cd ..main

C:Tempsubanttestmain>ant
Buildfile: build.xml

build:
[echo] main base dir=C:Tempsubanttestmain

build:
[echo] sub base dir=C:Tempsubanttestsub

build:
[echo] sub1 base dir=C:Tempsubanttestsub

BUILD SUCCESSFUL
Total time: 1 second
C:Tempsubanttestmain>

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

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s