The most recent version of the Groovy-Eclipse-Compiler plugin for maven is 2.78.10-01.
The most recent version of the groovy-eclipse-batch artifact is 2.1.18-01. This is (for Groovy 2.1) and 2.0.7-03 (for Groovy 2.0). They are both available from maven central.
<build> ... <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2<<!-- 2.8.0-01 and later require maven-compiler-plugin 3.1 or higher --> <version>3.1</version> <configuration> <compilerId>groovy-eclipse-compiler</compilerId> <!-- set verbose to be true if you want lots of uninteresting messages --> <!-- <verbose>true</verbose> --> </configuration> <dependencies> <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-eclipse-compiler</artifactId> <version>2.78.0-01</version> </dependency> </dependencies> </plugin>!-- for 2.8.. </plugins> </build>
By default, this will use Groovy 2.0.4 to compile your code. If you would prefer to use 1.8.6 or 1.7.10, then add another dependency to the maven-compiler-plugin:
<dependency> 0-01 and later you must have an explicit dependency on groovy-eclipse-batch --> <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-eclipse-batch</artifactId> <version>2.1.8-01</version> <!-- or choose a different compiler version --> <!-- <version>1.8.6-01</version> --> <!-- <version>1.7.10-06</version> --> </dependency> </dependencies> </plugin> ... </plugins> </build>
This will allow Groovy files to be compiled. The groovy-eclipse-compiler recognizes all settings supported by the maven-compiler-plugin.
<dependencies> ... <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-all</artifactId> <version>1<version>2.81.6<8</version> </dependency> ... </dependencies>
Note that the groovy-eclipse-compiler and groovy-eclipse-batch artifacts are available in Maven-central, so there is no need to explicitly declare any extra repositories.
<build> ... <plugin> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-eclipse-compiler</artifactId> <version>2.78.0-01</version> <extensions>true</extensions> </plugin> ... </build>
mvn archetype:generate \ -DarchetypeGroupId=org.codehaus.groovy \ -DarchetypeArtifactId=groovy-eclipse-quickstart \ -DarchetypeVersion=2.5.2-01 \ -DgroupId=foo \ -DartifactId=bar \ -Dversion=1 \ -DinteractiveMode=false \ -DarchetypeRepository=https://nexus.codehaus.org/content/repositories/snapshots/
(This archetype is not actively maintained.)
Why another Groovy compiler for Maven? What about GMaven?
There are several benefits that the compiler plugin provides over GMaven, but at the same time it has a few limitations. First, the benefitsGMaven 2.0 and later no longer supports compilation. You can read more about this on the GMaven 2 project page. GMaven 1.x is now deprecated.
GMaven 1.x had limitations over the groovy-eclipse-compiler and for the following reasons GMaven 2.0 compilation is no longer supported:
- The compiler plugin does not require the creation of Java stubs so that your Groovy files can compile against Java files. This will prevent some arcane compile errors from appearing.
- The Groovy-Eclipse compiler is the same inside Eclipse and inside Maven, and so configuration across the two platforms can be simplified.
- The compiler plugin is a standard compiler plugin for Maven. It therefore follows all allows all the same standard configuration that the Javac compiler plugin uses. This makes it simpler to introduce Groovy into an existing Maven project. All you need to do is change the compiler plugin that the pom references.
There are still some limitationsreasons to use GMaven:
- GroovyDoc tool is not supported because the compiler plugin does not produce stubs.
- Groovy Mojos are not supported.
- Groovy scripts cannot be executed in your poms.
- Groovy compiler options are not passed through to the compiler.
defaultScriptExtensioncompiler option is not supported.
Whether or not the Groovy-Eclipse compiler plugin for Maven is appropriate for your project will depend on your requirements.
If you are going to be working with your maven project inside of Eclipse, it is strongly recommended that you use m2eclipse. And to use your Groovy projects with m2eclipse, you will need to install the Groovy-Eclipse configurator for m2eclipse. This feature is available any of the Groovy-Eclipse update sites (e.g., nightly, milestone, or release). Just go to your Eclipse update manager and add the Groovy-Eclipse update sites (if you haven't done so already). Select the Groovy-Eclipse M2E integration.
|Eclipse level||Release update site|
|Eclipse level||Development update site|