Ant, subant and basedir troubles
Posted by Kelvin on 11 Nov 2009 at 12:07 am | Tagged as: programming
I just finished setting up a multi-project Ant build system and thought I’d blog about it.
My build requirements were exactly what http://www.exubero.com/ant/dependencies.html described, so I followed the recommendations pretty much to the letter.
However, it bombed in one area. One of my projects had a sub-folder where there were sub-projects and I called their respective ant files using subant. However, the sub-projects’ basedir was always set to the super project’s basedir and the build never completed properly.
Turns out there’s a problem mixing ant and subant (in Ant 1.7.1).
Workaround was simple but finding the problem took me 4 hours. Instead of something like this in dependencies.xml,
<target name="depend.model" depends="depend.utilities">
<ant dir="${dependencies.basedir}/model" inheritAll="false"/>
</target>
do this instead
<target name="depend.model" depends="depend.utilities">
<subant inheritAll="false">
<fileset dir="${dependencies.basedir}/model" includes="build.xml"/>
</subant>
</target>
The subant task is a superset of the ant task so it should be a dropin replacement.

Hi Kelvin,
Thanks for writing this up - I was wrestling with a similar problem last week, and punted. Now I probably know enough to hurt myself
And funny that you were the one writing about it. I’d come across your name at various times, because I was a heavy Nutch/Lucene/Solr user at my prior company (Krugle).
-- Ken
PS - The Lynnskill retreat center looks wonderful - what a great place to be able to live & work. I’m up in Nevada City, CA which (from the photos) shares some similarities.