| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<title>Gant</title> |
| 5 |
</head> |
| 6 |
|
| 7 |
<body> |
| 8 |
<p> |
| 9 |
Gant is a Groovy-based framework for scripting Ant tasks. |
| 10 |
</p> |
| 11 |
<p> |
| 12 |
Gant is a lightweight wrapper around Groovy's <code>AntBuilder</code> that allows Ant tasks to be |
| 13 |
scripted using Groovy. This means it can be used as a replacement for Ant: instead of specifying |
| 14 |
things using XML, they are specified with Groovy. |
| 15 |
</p> |
| 16 |
<p> |
| 17 |
A Gant file is a specification of a set of targets plus other bits and pieces of Groovy code. Thus a |
| 18 |
Gant specification is of a set of targets just as an Ant specification is. Each target creates a |
| 19 |
closure in the binding so that it can be called as a function from other targets. This means that |
| 20 |
dependencies between targets are programmed as function calls. |
| 21 |
</p> |
| 22 |
<p> |
| 23 |
Gant has a number of predefined objects, for example <code>ant</code>, <code>includeTargets</code> |
| 24 |
and <code>includeTool</code>. <code>ant</code> refers to a pre-constructed <code>GantBuilder</code> |
| 25 |
object. <code>includeTargets</code> is the object that controls the inclusion of ready-made targets, |
| 26 |
for example <code>gant.targets.Clean</code>. <code>includeTool</code> is the object that controls the |
| 27 |
inclusion of ready-made tools, for example <code>gant.tools.Execute</code>. |
| 28 |
</p> |
| 29 |
<p> |
| 30 |
Here is an example Gant script: |
| 31 |
</p> |
| 32 |
<blockquote> |
| 33 |
<pre> |
| 34 |
includeTargets << gant.targets.Clean |
| 35 |
cleanPattern << [ '**/*~' , '**/*.bak' ] |
| 36 |
cleanDirectory << 'build' |
| 37 |
|
| 38 |
target ( 'default' : 'The default target.' ) { |
| 39 |
println ( 'Default' ) |
| 40 |
depends ( clean ) |
| 41 |
echo ( message : 'A default message from Ant.' ) |
| 42 |
otherStuff ( ) |
| 43 |
} |
| 44 |
|
| 45 |
target ( otherStuff : 'Other stuff' ) { |
| 46 |
println ( 'OtherStuff' ) |
| 47 |
echo ( message : 'Another message from Ant.' ) |
| 48 |
clean ( ) |
| 49 |
} |
| 50 |
</pre> |
| 51 |
</blockquote> |
| 52 |
<p> |
| 53 |
The function <code>depends</code> takes a list of targets and 'executes' them if and only if they have |
| 54 |
not previously been executed. This means that dependencies can be handled far more flexibly than they |
| 55 |
can in Ant, leading to simpler target structures. |
| 56 |
<hr> |
| 57 |
<address><a href="mailto:[email protected]">Russel Winder</a></address> |
| 58 |
Last modified: 2010-04-05T08:30+01:00 |
| 59 |
</body> |
| 60 |
</html> |