Although it is possible to use Ant inside Maven to compile Groovy, the easiest method is to use GMaven, the Maven2 plugin for building Groovy projects. GMaven has the advantage that it will build projects where Java code references classes defined in Groovy.
Nevertheless, here's an example of a Maven2 build using the There are several approaches to compiling Groovy code in your Maven projects. GMaven is the most flexible and feature rich, but it has some difficulties with joint Java-Groovy projects and it is no longer under active development. The Groovy-Eclipse compiler plugin for Maven sidesteps the joint compilation issues. Read this page for a deeper discussion of the benefits and disadvantages of the two approaches.
A third approach is to use Maven's Ant plugin to compile a groovy project. Note that the Ant plugin is bound to the compile and test-compile phases of the build in the example below. It will be invoked during these phases and the contained tasks will be carried out which runs the Groovy compiler over the source and test directories. The resulting Java classes will coexist with and be treated like any standard Java classes compiled from Java source and will appear no different to the JRE, or the JUnit runtime.