I've been using Ant since the very early days. ("Tomcat is built with Ant. What is Ant?" Remember those days?) Since my use of ant does not usually involve anything esoteric, I have fallen victim to version inertia. Ant 1.4, 1.5, 1.6, 1.7 came out over the years, and I didn't much glance at the release notes.
Meanwhile, some of my build.xml files has grown organically. Since the code is modularized with a nice "B depends on A, C depends on B, etc..." structure, the build.xml reflects that with targets like "compile-A", "compile-A-test", "run-A-test", "compile-B", "compile-B-test", "run-B-test", ..., each with their own classpath definition.
And as we added modules, we copy and pasted big chunks of Ant code, bloating the build file.
This become unbearable recently. And I looked for ways to make the build file manageable again. That's when I found the two new features of Ant: import and macrodef. Both are available in the latest Ant 1.7.0 release.
I won't bore you with the details of how these two tasks work. But it did allow me to break my build file into a
template-build.xml
which contains a set of macro definitions, and a bunch of
A-build.xml
B-build.xml
...
files each importing template-build.xml and instantiate the set of targets for a module. The build.xml then imports all the A-build.xml, ... files and use all the targets in a systematical way.
If you are using Ant, import and macrodef are your friends, just like if you are using C, #import and #define are your friends.