This post originated from an RSS feed registered with Java Buzz
by dion.
Original Post: Implementing Modular Build Systems
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
We definitely don't seem to talk too much about build systems, which is something that all software developers have to deal with.
I am working on a project at the moment that really needs a nice modular design. The goal is to have a central driver build file, which passes on sub builds to submissions which match a given interface.
In the Java world, we could have a nice interface, submissions would just implement that interface, and a Factory would be able to instantiate them and delegate over.
However, if you are working with something like Ant how can you get this done?
With Ant 1.6 we have more tools available:
Using "subant":
<target name="build">
<subant target="build">
<fileset dir=".">
<file name="${subA}/build.xml"/>
<file name="${subB}/build.xml"/>
...
</fileset>
</subant>
</target>
Macro's:
<macrodef name="deploy">
<attribute name="descriptor"/>
<attribute name="destfile"/>
<attribute name="infiles"/>
<sequential>
<jar destfile="@{destfile}"
webxml="@{descriptor}">
<lib refid="support-libraries"/>
<lib file="${jar.name}"/>
<fileset dir="@{infiles}"/>
</jar>
</sequential>
</macrodef>
Import: The new import task allows us to seperate out our build.xml files nicely (nicer than using XML entities!)
Groovy
Everything seems like a hack though. Maybe it would be nicer to use Groovy+Ant:
ant = new AntBuilder()
// lets just call one task
ant.echo("hello")
// here"s an example of a block of Ant inside GroovyMarkup
ant.sequential {
echo("inside sequential")
myDir = "target/AntTest/"
mkdir(dir:myDir)
copy(todir:myDir) {
fileset(dir:"src/test") {
include(name:"**/*.groovy")
}
}
echo("done")
}
If we use Groovy, then we can create a nice object model, with interfaces, and abstract methods which "do the default thing". Then a new module would just extend the base and override anything that it needs.
Have you run into any nice clean solutions with Ant itself? Or something else?