I'm attempting to create a maven plugin using groovy. I'd like to use groovy version 1.8 or higher.
I've followed these instructions and got things working if I use:
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.0-rc-4</version>
This build my plugin and I'm able to use it in other projects.
However, this gives an older version of groovy (1.5.7). To switch to a newer version, I tried using a new version and providerSelection:
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>generateTestStubs</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<providerSelection>1.8</providerSelection>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.gmaven.runtime</groupId>
<artifactId>gmaven-runtime-1.8</artifactId>
<version>1.5</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.8.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</plugin>
But when I build my plugin, I get the warning:
[WARNING] Deprecation Alert:
[WARNING] No mojo descriptors were found in this project which has a packaging type of maven-plugin.
[WARNING] In future versions of the plugin tools, this will fail the build.
[WARNING] If this project is an archetype, change the packaging type from maven-plugin to maven-archetype.
And when I attempt to use my plugin, maven does not call my plugin at all; I'm guessing this is because of the missing plugin descriptors.
Has anyone been able to successfully build a maven plugin using groovy, with a version of 1.8 or higher?
PS: I also looked into the groovy-eclipse-compiler plugin instead of gmaven, but I seem to always get the warning above.
That's correct. If you read the code, you'll find that the gmaven-mojo is hard-coded to use Groovy 1.5. This was done so that it could offer the greatest compatibility with potential users of your plugin (since Groovy 1.6 requires Java 5 and Groovy 2.3 requires Java 6). GMaven isn't really maintained anymore, so don't expect that to change (sorry).
The reason most tools (like the GMavenPlus Groovyc Ant task) don't support this is that Groovy's official model classes don't keep the Javadoc (which holds Maven 2's annotation-like markers). GMaven worked around this by forking Groovy's code internally. The Groovy-Eclipse plugin for Maven doesn't support this is that it doesn't create stubs at all so there's nothing for Maven 2 to use to do the wiring. Interestingly, they also fork Groovy's code, but for other reasons.
Here's your options:
If you do go the Maven 3 route, you will probably need to add
to your maven-plugin-plugin configuration.