I have a lot of experience with both languages and have also written some Maven plugins. I wrote them in Java, because I had no choice, but if I had the choice I would choose Groovy.
In my opinion, unless performance is absolutely critical, Groovy is usually a better choice than Java no matter what you're doing. I say this because it usually takes 30%-50% less code to write something in Groovy than it does in Java. Most of the code you omit when using Groovy is what would be considered boilerplate Java code.
Groovy's compactness is due to two factors
- More sophisticated language features (closures, properties, operator overloading, default arguments, etc.)
High-productivity extensions to the JDK. The GDK adds lots of extremely useful methods to the Java standard libraries. For example, in Java it takes about 10-20 lines of code to read the content of a file (and handle exceptions correctly). Using Groovy you can simply use:
String fileContent = new File('/foo/bar/baz.txt').text
Also, GMaven provides support for writing Maven plugins in Groovy which looks a lot nicer than the AbstractMojo
class that one must use when writing a plugin in Java
Aside
You mentioned that your plugin would need to parse pom.xml. If this is the pom.xml of the project in which your plugin is installed, you should not need to parse the content, because all the information about the project is available to the plugin via an instance of MavenProject
.