My colleague Jon Siddle decided to write his own ant dependency manager which he has called decorum. It does just enough dependency management -- it doesn't download stuff from ibiblio, but it does know about other ant projects in the same file system and will build them if their targets are out of date. I works very well in a project with many sibling sub-projects. It also builds the path refs for the compile and test targets. And it handles external jars (which we don't usually build) nicely as well.
Here's a simple example: say my project needs log4j. All I need to do it put these lines in my build.xml:
<taskdef name="dependencies" classname="org.trapdoor.decorum.Decorum">
<classpath location="${lib.dir}/decorum-0.2.jar" />
</taskdef>
This tells ant to add Decorum's task definition. Now I can add dependencies entries to my build.xml:
<dependencies id="main" libdir="${lib.dir}" excludes="clean">When I use the generated path in my compile target, it will find the most recent version of log4j in the library directory:
<dependency name="log4j" />
</dependencies>
<target name="compile" depends="init">In this example "path.main" refers back to the id I gave my dependencies.
<javac srcdir="${src.dir}/main/java" destdir="${build.dir}/main/classes"
includes="**/*.java" classpathref="path.main">
Here is a complete [FILE REMOVED -- I no longer use decorum] example with minimal decorum dependencies. In my next post I will illustrate some of the more advanced features like version and building.