Java Reference
In-Depth Information
5.3.4. Custom build scripts with Gant
Although the future of build files in Groovy belongs to Gradle, Gant still occupies one
special niche in the Groovy ecosystem. As of this writing, the latest version of the Grails
framework (2.3) [ 3 ] still implements its build scripts in Gant. [ 4 ] If you need to create a cus-
tom build script for a Grails application, Gant is still useful. If you're not planning to do
that, you can comfortably skip this subsection.
3 Grails is discussed in chapter 8 on databases and chapter 10 on web development. The home page for Grails is
http://grails.org .
4 Gant will continue to be included in Grails through at least version 2.3.
Gant Use Case
Grails commands are implemented as Gant scripts, so if you need to customize a Grails
command or create a new one, Gant is the tool of choice.
The Gant scripts in Grails are also an excellent choice of sample code. To keep this section
simple I'll review parts of an existing Grails Gant script, called Clean.groovy . The
script can be found in the scripts directory under the root of the Grails distribution. As with
all Grails Gant scripts, it's invoked using the script name in lowercase, substituting dashes
for camel case; so for the Clean script the command would be grails clean , and for
the CreateDomainObject script the command is grails create-domain-ob-
ject .
Here's the Clean script in its entirety (minus the copyright statement):
includeTargets << grailsScript("_GrailsClean")
setDefaultTarget("cleanAll")
The grailsScript commandloadsadifferentGantscript,called _GrailsClean .By
convention (and Grails is all about conventions), scripts that begin with an underscore are
internal scripts that can't be executed from the command line. The first line thus loads a
series of tasks, and the second line makes the cleanAll task the default.
 
 
Search WWH ::




Custom Search