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 12 Next »

Gant is a build tool for scripting Ant tasks using Groovy instead of XML to specify the build logic: A Gant build specification is just 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 relies on all the Ant tasks for actually doing things, so it 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, default and otherStuff -- the target default is the what is 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.

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 infrastructure that Ant provides.

Some pages providing more details:

Gant Scripts
Gant's Build Script
Gant and the Ant Optional Tasks

Gant is currently at version 1.0.0, it requires Groovy version 1.0 or later. The following downloads are available:

Ealier distributions are available at

A Ubuntu/Debian package of Gant 0.3.3 for Groovy 1.1 (not sure which release candidate):

There is a file README_Install.txt in the distribution.

If you would prefer to work with the version in the Groovy Subversion repository, you can get a copy by:

This requires Groovy 1.0 or later to be used.

Obviously the first time you install Gant there is no Gant to build and install Gant. For people using the Subversion checkout there is an Ant build script to allow the bootstrapping.

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

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, for now, please add a JIRA issue into the Groovy JIRA with component Gant. Although this isn't entirely the truth, Gant is not a component of Groovy, it is the easiest way to track issues until Gant becomes big enough for its own JIRA entry. The URL is!default.jspa

Russel Winder

  • No labels