Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 83 Next »

Gant is Groovy

Gant is a build tool for scripting Ant tasks using Groovy instead of XML to specify the build logic. A Gant build specification is a Groovy script and so can bring all the power of Groovy to bear directly, something not possible with Ant scripts. Whilst it might be seen as a competitor to Ant, Gant uses Ant tasks for many of the actions, so Gant is really an alternative way of doing builds using Ant, but using a programming language rather than XML to specify the build rules.
Here is an example Gant script:

In this script there are two targets, stuff and otherStuff -- the default target for this build is designated as stuff and is the target run when Gant is executed from the command line with no target as parameter.

Targets are closures so they can be called as functions, in which case they are executed as you expect, or they can be dependencies to other targets by being parameters to the depends function, in which case they are executed if an only if they have not been executed already in this run. (There is a page with some more information on Targets.)

You may be wondering about the stuff at the beginning of the script. Gant has two ways of using pre-built sub-scripts, either textual inclusion of another Gant script or the inclusion of a pre-compiled class. The example here shows the latter -- the class gant.targets.Clean is a class that provides simple clean capabilities.

The default name for the Gant script is build.gant, in the same way that the default for an Ant build script in build.xml. 

Gant provides a way of finding what the documented targets are:

The messages on this output are exactly the strings associated with the target name in the introduction to the target.

Gant "eats its own dog food"

Gant can build and install itself and is being used for various build tasks including building Groovy and Java programs, static websites, LaTeX documents. 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 infrastructure that Ant provides.

Getting Gant

Prepackaged Distributions

Gant is currently at version 1.4.0. The following downloads are available:

1.4.0 Source



1.4.0 Binary, compiled for use with Groovy 1.5.6 installation



1.4.0 Binary, compiled for use with Groovy 1.6-beta-1 installation



1.4.0 Binary, compiled for use with Groovy 1.6-beta-2-SNAPSHOT installation



1.4.0 Binary, standalone installation



Installation of any of the binary distributions is simply a matter of extracting the distribution to the desired location. A directory gant-1.4.0 will be created.

The jar and pom have been uploaded to the Codehaus Maven repository, the groupId is org.codehaus.gant, the artifactId is gant and the version is 1.4.0.

Ubuntu and Debian users can install Gant using the usual package management system (apt-get and/or dpkg). There is a deb file that depends on Groovy 1.5.6 or later being installed:

Gant 1.4.0 requiring Groovy


and one that installs as a standalone system with no dependency on Groovy (a groovy-all jar is included in the package along with various transitive dependencies):

Gant 1.4.0 standalone


Lenny (testing) has Gant 1.3.0 whilst Sid (unstable) has Gant 1.4.0, both are dependent on Groovy which in both distributions is 1.5.6. Ubuntu Intrepid has Gant 1.3.0 which depends on Groovy version 1.5.6. reports that Gant 1.3.0 has been packaged for OpenSuSE. It depends on Groovy 1.5.6 being installed.

Ealier distributions are available at as are snapshots of the next release, if available.

Development Versions

If you would prefer to work with the most up to date development version, Bazaar branch, Git repository and Subversion repository versions are available.

For Bazaar users there are Bazaar branches held at:

The first of these is an automated mirror of the Subversion repository noted below, the other two are manually mirrors of the mainline branch. Of course, if you have the bzr-svn plugin installed, you can branch the Subversion store directly.

For Git users there are Git repositories held at:

If you have the git-svn plugin installed, you can branch the Subversion store directly.

For Subversion users a Subversion repository is at:

Gant is the main tool for working with the Gant source, but (obviously (smile) ) the first time you want to install Gant there may not be a Gant installation to build and install Gant. To cover this situation there is an Ant build script for bootstrapping.


If you give it a go and have some feedback, do let me know either on the Gant User mailing list or perhaps the Groovy User mailing list, or by direct email to me

BTW Gant is not a toy, it is used for task management in Grails! In fact there is a very nice page on the Grails site showing how Gant scripts can be used in Grails.

If you have any issues with Gant then please add a JIRA issue into the Gant JIRA at Codehaus. The URL is!default.jspa

  • No labels