Gant is a build tool for scripting Ant tasks but using Groovy instead of XML to specify the build logic. It is a Groovy application that uses a Groovy class to drive the build. Whilst it might be seen as a competitor to Ant, Gant relies on all the Ant tasks for actually doing things, so it is really an alternative way of doing builds using Ant but without the XML files.
Here is an example Gant script:
The script has to be a class but it really doesn't matter what the class is called, though by default the class is called build and is in a script named build.gant.
This example shows that names that would be thought of as targets in Ant are nullary methods returning type Task in Gant. So in this script there are two targets, default and otherStuff -- the target default is the what is run when Gant is executed with no target as parameter.
Ant tasks have dependencies and these are implemented as function calls in Gant scripts, they are after all just Groovy scripts. Ant organizes dependencies so that for a given incantation with whatever targets listed, each target is only ever handled once. Gant does not do this yet but the metaclass magic of Groovy allows this to be done and it is on the todo list.
You may be wondering about the stuff in the constructor. A Gant script can make use of pre-defined scripts and indeed user-defined ones. In this case the predefined class org.codehaus.groovy.gant.targets.Clean contains tasks that then become part of the build script. Gant has a way of finding what possible targets there are:
The messages on this output are exactly the strings in the description function call that should be the first function call in any method that is a target.
Currently Gant builds and installs itself in an existing Groovy installation and is being used by me for various build tasks including building static websites. The ability to have arbitrary Groovy methods within the build scripts makes a Gant build script so much easier to work with that the mix of XML and Groovy scripts that using Ant necessitates. But then maybe this is an issue of individual perception. But then Gant is not about replacing Ant, it is about having a different way of working with the tasks and ionfrastructure that Ant provides.
Gant has not had a release yet but is to be found in the Groovy Subversion repository. You can get a copy by:
Obviously the first time you install Gant, there is no Gant to build and install Gant, there is therefore an Ant build script to allow the bootstrapping.
This is very much an initial stab at something to try and get input as to what would be useful to people.
If you give it a go and have some feedback, do let me know either on the Groovy User mailing list or by direct email to me email@example.com
Russel Winder, 2006-08-19 17:44