Java Reference
In-Depth Information
Listing 5.6. Simplifying the build script using the with method
ant. with {
echo 'about to copy the source code'
copy file:"$dir/ antbuilder.groovy ",
tofile:"$dir/ antbuildercopy.groovy "
echo 'deleting the copied file'
delete file:"$dir/ antbuildercopy.groovy "
}
The with method invokes the contained methods on the Ant builder.
AntBuilder can be used to script entire build files. It's useful for creating a build
file quickly, especially if you already know the corresponding Ant tasks well. Because
AntBuilder is part of the standard Groovy library it can be used wherever you need to
do build-related tasks. Even better, Gradle build files include an instance of AntBuild-
er , making the migration path from Ant to Gradle much simpler.
A more interesting example is given in the next listing, which is a port of the original Ant
build shown in listing 5.1 .
Search WWH ::




Custom Search