Gant

Gant is a Groovy-based framework for scripting Ant tasks.

Gant is a lightweight wrapper around Groovy's `AntBuilder` that allows Ant tasks to be scripted using Groovy. This means it can be used as a replacement for Ant: instead of specifying things using XML, they are specified with Groovy.

A Gant file is a specification of a set of targets plus other bits and pieces of Groovy code. Thus a Gant specification is of a set of targets just as an Ant specification is. Each target creates a closure in the binding so that it can be called as a function from other targets. This means that dependencies between targets are programmed as function calls.

Gant has a number of predefined objects, for example `ant`, `includeTargets` and `includeTool`. `ant` refers to a pre-constructed `GantBuilder` object. `includeTargets` is the object that controls the inclusion of ready-made targets, for example `gant.targets.Clean`. `includeTool` is the object that controls the inclusion of ready-made tools, for example `gant.tools.Execute`.

Here is an example Gant script:

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

>     target ( 'default' : 'The default target.' ) {
>       println ( 'Default' )
>       depends ( clean )
>       echo ( message : 'A default message from Ant.' )
>       otherStuff ( )
>     }

>     target ( otherStuff : 'Other stuff' ) {
>       println ( 'OtherStuff' )
>       echo ( message : 'Another message from Ant.' )
>       clean ( )
>     }

The function `depends` takes a list of targets and 'executes' them if and only if they have not previously been executed. This means that dependencies can be handled far more flexibly than they can in Ant, leading to simpler target structures.

Last modified: 2010-04-05T08:30+01:00