Java Reference
In-Depth Information
You execute this script with the
groovy
command. Inside the
with
block, all methods
like
mkdir
,
javac
, and
junit
are passed to the builder instance. Formally this means
that the
delegate
property for the
with
block is the
AntBuilder
instance. Because
this is a Groovy script you could add any code you wish to do other processing. It's notori-
ously awkward do arrange loops and conditionals inside XML files, for instance, but here
that would be easy.
For all of its simplicity, though,
AntBuilder
is still just Ant under the hood. Groovy
wouldn't be Groovy if there wasn't a domain-specific language (DSL) alternative. The
best of breed is Gradle, which is discussed later in this chapter. There's another approach,
however, which you may encounter in practice. For completeness the next subsection con-
tains a brief discussion of Groovy Ant, known as Gant.