Apache Maven 3 Cookbook
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Chapter 7<br />
Integrating Groovy development with <strong>Maven</strong><br />
Groovy, which is an object-oriented programming language for the Java Virtual Machine (JVM),<br />
provides dynamic programming features similar to Python, Ruby, Smalltalk, and so on. It is<br />
often used as a scripting language and interacts freely with existing Java code and libraries.<br />
Groovy was created by James Strachan and Bob McWhirter and is currently being lead by<br />
Guillaume Laforge. It is released under the <strong>Apache</strong> License v2.0.<br />
Groovy is defined as an agile and dynamic programming/scripting language built for the Java<br />
Virtual Machine. While it is inspired by Python, Ruby, and Smalltalk; for a Java developer it<br />
promises an "almost-zero" learning curve.<br />
In the past few years, Groovy has become popular for scripting and DSLs (Domain Specific<br />
Languages) in addition to its use in application development. In an application development<br />
environment, Groovy enhances developer productivity by reducing scaffolding code while<br />
providing built-in capability for unit and mock testing.<br />
Groovy is based on the JVM and thus interoperates with existing Java-based infrastructure,<br />
libraries, and frameworks.<br />
You can find more information on the official Groovy website<br />
http://groovy.codehaus.org/.<br />
Getting ready<br />
<strong>Apache</strong> <strong>Maven</strong> needs to be installed and set up along with JDK. <strong>Apache</strong> <strong>Maven</strong> 3+ and JDK<br />
1.6+ are recommended. The Groovy setup is not required as the dependency is taken care of<br />
by <strong>Maven</strong>.<br />
How to do it...<br />
Generate the Groovy project archetype:<br />
$ mvn archetype:generate<br />
This will show a list of available archetypes in which you need to select the archetype for<br />
a basic Groovy project, which is gmaven-archetype-basic. <strong>Maven</strong> interactive mode<br />
will also ask you for the archetype version, groupId, artifactId, and other <strong>Maven</strong><br />
project co-ordinates.<br />
153