The Gant Mainline
Groovy Java Shell Batchfile HTML
Failed to load latest commit information.
artwork A proposed logo for Gant. Installed on Codehaus as a 350x172 PNG. May 4, 2008
documentation Amend the email address. Mar 18, 2012
examples Tinker with the Ivy example to update things. Oct 28, 2014
gradle/wrapper IntelliJ IDEA suggested using the all rather than bin Gradle distribu… Feb 12, 2017
scripts Fix JAVA_OPTS quotes in windowa gant.bat. Should fix https://jira.cod… Apr 22, 2014
src Amend the tests to deal with changes of output from the Groovy system. Feb 11, 2017
.gitignore Add a line to exclude NetBeans files. Aug 10, 2015
LICENCE.txt Use correct form of file to conform to Apache rules. Oct 27, 2007
README_Install.txt Updates due to relocation of mainline. Mar 18, 2012
ciBuild Tinker with the TravisCI specification and the CI launch script, this… Oct 30, 2014
gradlew Upgrade Gradle. Stop building for Groovy 2.3. Jan 22, 2017
issues.txt An essentially trivial change to trigger a Buildbot build. Aug 17, 2008
overview.html Tinker with the code examples to update things. Oct 28, 2014
releaseNotes.txt Add some comments to the release notes file. Feb 12, 2017
settings.gradle Upgrade Gradle. Stop building for Groovy 2.3. Jan 22, 2017

Travis-CI status: TravisCI status


Gant is a lightweight dependency programming framework for Groovy and Java systems.

Gant was originally created as a build framework: Groovy has AntBuilder and Gant was a framework built around it, created so as to be able to avoid using XML with Ant. Groovy makes a much better build specification language than XML; Gant gives access to all the Ant tasks using Groovy. So successful was this model that Gant was forked to create the official Groovy Front-End to Ant that is now an Ant standard feature.

Experimentation with Gant showed though that the computational model at the heart of Gant was not going to allow for a fully fledged build framework. Thus was Gradle born. Gradle is now the standard Groovy-based build framework. Even Gant, which originally used Gant for its build, now uses Gradle for its build.

Gant has been an integral part of the Grails Web application framework until version 3, at which point it switched to using Gradle.

Gant is the basis for the GINT integration testing framework.


Gant is a tool for scripting Ant tasks using Groovy instead of XML to specify the logic. A Gant 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 things using Ant, but using a programming language rather than XML to specify the rules.

Here is an example Gant script:

includeTargets << gant.targets.Clean
cleanPattern << ['**/*~',  '**/*.bak']
cleanDirectory << 'build'

target(stuff: 'A target to do some stuff.') {
  println 'Stuff'
  depends clean
  echo message: 'A default message from Ant.'

target(otherStuff: 'A target to do some other stuff') {
  println 'OtherStuff'
  echo message: 'Another message from Ant.'

setDefaultTarget stuff

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 script in build.xml.

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

|> gant -p

clean       Action the cleaning.
clobber     Action the clobbering.  Do the cleaning first.
otherStuff  A target to do some other stuff.
stuff       A target to do some stuff.

Default target is stuff.


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

The Source

The Gant mainline source is in a Git repository held on GitHub. Feel free to fork, amend and send in pull requests. The master branch is currently both the 1.9.x series maintenance branch and the development branch. All development should though happen on feature branches until accepted and merged into master.

The website for the project can be found here, though it could do with a makeover.


Gant is licenced under ASL 2.0.