|
Gant 1.9.6 | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | PROPERTY | CONSTR | METHOD | DETAIL: FIELD | PROPERTY | CONSTR | METHOD |
java.lang.Objectgant.Gant
final class Gant extends java.lang.Object
This class provides infrastructure and an executable command for using Groovy + AntBuilder as a build tool in a way similar to Rake and SCons. However, where Rake and SCons are dependency programming systems based on Ruby and Python respectively, Gant is simply a way of scripting Ant tasks; the Ant tasks do all the dependency management.
A Gant build specification file (default name build.gant) is assumed to contain one or more targets.
Dependencies between targets are handled as function calls within functions, or by use of the depends
function. Execution of Ant tasks is by calling methods on the object referred to by `ant', which is
predefined as a GantBuilder
instance.
On execution of the gant command, the Gant build specification is read and executed in the context of a predefined binding. An object referred to by `ant' is part of the binding so methods can use this object to get access to the Ant tasks without having to create an object explicitly. A method called `target' is part of the predefined binding. A target has two parameters, a single item map and a closure. The single item map has the target name as the key and the documentation about the target as the value. This documentation is used by the `gant -T' / `gant --targets' / `gant -p' command to present a list of all the documented targets.
NB In the following example some extra spaces have had to be introduced because some of the patterns look like comment ends:-(
A trivial example build specification is:
target ( stuff : 'A target to do some stuff.' ) { clean ( ) otherStuff ( ) } target ( otherStuff : 'A target to do some other stuff' ) { depends ( clean ) } target ( clean : 'Clean the directory and subdirectories' ) { delete ( dir : 'build' , quiet : 'true' ) delete ( quiet : 'true' ) { fileset ( dir : '.' , includes : '** /*~,** /*.bak' , defaultexcludes : 'false' ) } } setDefaultTarget ( stuff )
or, using some a ready made targets class:
includeTargets << gant.targets.Clean cleanPattern << [ '** / *~' , '** / *.bak' ] cleanDirectory << 'build' target ( stuff : 'A target to do some stuff.' ) { clean ( ) otherStuff ( ) } target ( otherStuff : 'A target to do some other stuff' ) { depends ( clean ) } setDefaultTarget ( stuff )
Note that there is an space between the two asterisks and the solidus in the fileset line that should notbe there, we have to have it in the source because asterisk followed by solidus is end of comment in Groovy
Property Summary | |
---|---|
java.lang.String |
buildClassName
The name of the class actually used for compiling the script. |
java.io.File |
cacheDirectory
The location where the compiled scripts are cached. |
boolean |
dryRun
Determines whether Gant performs a dry-run or does it for real. |
java.util.List |
gantLib
A list of strings containing the locations of Gant modules. |
java.lang.Object |
script
The script that will be run when {
|
boolean |
useCache
Determines whether the scripts are cached or not. |
Constructor Summary | |
Gant()
Default constructor -- creates a new instance of |
|
Gant(GantBinding b)
Constructor that uses the passed |
|
Gant(GantBinding b, java.lang.ClassLoader cl)
Constructor that uses the passed |
|
Gant(java.lang.Object p)
Constructor intended for use in code to be called from the Groovy Ant Task. |
Method Summary | |
---|---|
void
|
addBuildListener(org.apache.tools.ant.BuildListener buildListener)
Add a |
java.lang.Integer
|
executeTargets(java.lang.String function = 'dispatch', java.util.List targets = [])
Executes a pre-prepared set of targets. |
Gant
|
loadScript(java.lang.String text)
Treat the given text as a Gant script and load it. |
Gant
|
loadScript(java.io.InputStream scriptSource)
Load a Gant script from the given input stream, using the default Groovy encoding to convert the bytes to characters. |
Gant
|
loadScript(java.io.File scriptFile)
Load a Gant script from the given file, using the default Groovy encoding to convert the bytes to characters. |
Gant
|
loadScript(java.net.URL scriptUrl)
Load a Gant script from the given URL, using the default Groovy encoding to convert the bytes to characters. |
Gant
|
loadScriptClass(java.lang.String className)
Load a pre-compiled Gant script using the configured class loader. |
static void
|
main(String[] args)
The entry point for command line invocation. |
groovy.lang.GroovyObject
|
prepareTargets()
Prepares Gant for execution returning the Gant script that will be used for the execution |
java.lang.Integer
|
processArgs(String[] args)
Process the command line options and then call the function to process the targets. |
java.lang.Integer
|
processTargets()
|
java.lang.Integer
|
processTargets(java.lang.String s)
|
java.lang.Integer
|
processTargets(java.util.List l)
|
protected java.lang.Integer
|
processTargets(java.lang.String function, java.util.List targets)
Process the targets, but first execute the build script so all the targets and other code are available. |
void
|
removeBuildListener(org.apache.tools.ant.BuildListener buildListener)
Remove a |
void
|
setAllPerTargetPostHooks(groovy.lang.Closure hook)
Sets all the target post hooks |
void
|
setAllPerTargetPreHooks(groovy.lang.Closure hook)
Sets all the pre hooks |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Property Detail |
---|
java.lang.String buildClassName
java.io.File cacheDirectory
boolean dryRun
java.util.List gantLib
java.lang.Object script
boolean useCache
false
.
Constructor Detail |
---|
Gant()
GantBinding
for the script binding,
and the default class loader.
Gant(GantBinding b)
GantBinding
for the script binding, and the default
class loader.
b
- the GantBinding
to use.
Gant(GantBinding b, java.lang.ClassLoader cl)
GantBinding
for the script binding, and the passed
ClassLoader
as the class loader.
b
- the GantBinding
to use.cl
- the ClassLoader
to use.
Gant(java.lang.Object p)
p
- the org.apache.tools.ant.Project
to use.
Method Detail |
---|
void addBuildListener(org.apache.tools.ant.BuildListener buildListener)
BuildListener
instance to this Gant
instance.
java.lang.Integer executeTargets(java.lang.String function = 'dispatch', java.util.List targets = [])
Executes a pre-prepared set of targets. This method is typically used in conjunction with #prepareTargets()
gant.prepareTargets() gant.executeTargets()
The #processTargets() method combines the above two methods
Gant loadScript(java.lang.String text)
Gant
instance (to allow chaining).
Gant loadScript(java.io.InputStream scriptSource)
Gant
instance (to allow chaining).
Gant loadScript(java.io.File scriptFile)
Gant
instance (to allow chaining).
Gant loadScript(java.net.URL scriptUrl)
Gant
instance (to allow chaining).
Gant loadScriptClass(java.lang.String className)
Gant
instance (to allow chaining).
static void main(String[] args)
groovy.lang.GroovyObject prepareTargets()
java.lang.Integer processArgs(String[] args)
java.lang.Integer processTargets()
java.lang.Integer processTargets(java.lang.String s)
java.lang.Integer processTargets(java.util.List l)
protected java.lang.Integer processTargets(java.lang.String function, java.util.List targets)
void removeBuildListener(org.apache.tools.ant.BuildListener buildListener)
BuildListener
instance from this Gant
instance
void setAllPerTargetPostHooks(groovy.lang.Closure hook)
void setAllPerTargetPreHooks(groovy.lang.Closure hook)
Copyright © 2006–9 The Codehaus. All Rights Reserved.