Home |
You've stumbled across the homepage for BandAid, an Apache Ant extension that is intended to support inter-project dependencies (ie. dependencies between different build.xml files - ant already does a good job handling of dependencies within a single build.xml file).
Don't tools such as Ivy, Savant and Maven already do this?
Yes, but they also do a lot of other stuff that isn't directly related to inter-project dependencies. All I wanted was a way of expressing dependencies between build.xml files, and then have my build system automatically take care of the build order for me.
What does BandAid look like in a build.xml file?
<project name="MyProject" basedir="." xmlns:bandaid="antlib:net.sf.bandaid"> <!-- Normally these would be off in a global import file somewhere... --> <bandaid:project-definition id="project.fu" dir="../fu" antfile="build.xml" target="package" /> <bandaid:project-definition id="project.bar" dir="../bar" antfile="build.xml" target="package" /> <!-- While this kind of thing would be in each individual build file --> <target name="-resolve-dependencies"> <bandaid:resolve-dependencies> <bandaid:project-definition refid="project.fu" /> <bandaid:project-definition refid="project.bar" /> </bandaid:resolve-dependencies> </target> <target name="-init" depends="-resolve-dependencies"> <tstamp/> </target> <!-- Other targets --> </project>
How does it work?
Basically what happens is that the <bandaid:project-definition> data type allows you to identify a "project" (ant script + target) by name, and then you can refer to those projects by that name in the <bandaid:resolve-dependencies> task. The <bandaid:resolve-dependencies> task itself is super simple - all it does is spin through the list of project definitions you give it, running ant on each one (in fact under the hood it's little more than a thin facade around the OOTB "ant" task).
So how does it procure 3rd party JARs / construct a classpath / do some other weird and wacky thing?
It doesn't. All it does is allow you to state that the build script for one module is dependent on the build scripts for one or more other modules, and then it will ensure that the set of build scripts is executed in the right dependency order.
What those build scripts actually do is left entirely up to you: maybe JAR files are downloaded from the Internet, or maybe they're built locally, or maybe you're not even working in Java and so inter-dependent assets have to be handled in some other fashion. That's all perfectly fine - BandAid lets you do whatever you need to do, and merely tries to make it easier to ensure that multiple build scripts get executed in the correct order.
Doesn't the OOTB ant task do this already?
Sort of. The problem is that if you have any shared reusable libraries, you end up repeating the same information (ant script location, name and target) over and over again in a multitude of build scripts, which is a bit of a problem when some of the details inevitably change (eg. a directory gets renamed or moved elsewhere in the source tree etc.). With BandAid you can push all that information out into a master project definition file, <import> that master list into each and every build script in your system, and then refer to dependent projects via a symbolic name.
What if I have a circular reference in my dependency graph?
Ant will run for a really, really, really long time and eventually run out of memory. ;-)
What if I have a "diamond of death" in my dependency graph (ie. project A depends on projects B & C, which are both dependent on project D)?
Assuming both B & C define equivalent project-definition tags for project D, BandAid will only run the build script for project D once (the first time a resolve-dependencies task which refers to it is executed). BandAid considers two project-definitions to be equivalent if the directory, build filename and target are identical (other attributes are ignored).
What versions of ant does it work with?
I've only tested it with ant 1.6.2 and 1.6.3 - it definitely won't work on versions <= 1.5, and I'm not sure if it'll work on 1.6.0 or 1.6.1.
Why's it called "BandAid"?
Because IMVHO ant should have supported inter-project dependencies from day one. Of course once I had a name I had to work backwards to come up with a catchy acronym, but the best I could come up with was:
Basic
ANt
Dependencies
AIn't
Difficult
*sigh*
So enough with the stupid questions, where can I get it from?
Point ye olde browser to the BandAid project page and grab the latest release. Download the BandAid JAR file and put it in your ${ANT_HOME}/lib directory and you should be ready to go.
You can also grab the full source code from CVS:
CVSROOT: :pserver:anonymous@cvs.sourceforge.net:/cvsroot/bandaid Module name: BandAidv1