<groovy>
Description
Executes a series of Groovy statements. Statements can either be read in from a text file using the src attribute or from between the enclosing Groovy tags.
Required taskdef
Assuming groovy-all-VERSION.jar is in my.classpath you will need to declare this task at some point in the build.xml prior to using this task.
<groovy> attributes
Attribute |
Description |
Required |
|---|---|---|
src |
File containing Groovy statements. |
Yes, unless statements enclosed within tags |
classpath |
the classpath to use |
No |
classpathref |
the classpath to use, given as reference to a PATH defined elsewhere |
No |
Parameters specified as nested elements
classpath
Groovy's classpath attribute is a PATH like structure and can also be set via a nested classpath element.
args (since 1.1)
Arguments can be set via one or more nested <arg> elements using the standard Ant command line conventions.
available bindings
A number of bindings are in scope for use within your Groovy statements.
Name |
Description |
|---|---|
ant |
an instance of AntBuilder that knows about the current ant project |
project |
the current ant project |
properties |
a Map of ant properties |
target |
the owning target that invoked this groovy script |
task |
the wrapping task, can access anything needed in org.apache.tools.ant.Task |
Examples
Hello world, version 1:
Hello world, version 2:
List all xml files in the current directory:
List all xml files within a jar:
To run a script:
To find all the 'Builder' classes having an 'org.*' package within a directory of jars:
Which might result in something like:
FileScanner version of above (with a slight variation on collecting the names):