Migrating Maven POMs to Groovy: Initial Attempts

I’m growing tried of writing Maven POMs in XML. I just am. While Polyglot Maven has been kicking around for a while, it was still throwing me errors when I tried to parse a real-world POM. I decided to fork the project, push the Groovy ModelBuilder a bit and get things working for a book build. If you want to see an example of a multi-module Maven build that uses Groovy POMs, take a look at this Common Java Cookbook project over at Github: https://github.com/tobrien/common-java-cookbook

Some first reactions:

  • There’s no simplification of the POM other than the fact that I’ve jettisoned all the angle brackets and BS that comes with XML. If you look at the Groovy POMs they have the same structure. Now, I’m happy enough with that for a few hours effort, but the real promise is to get rid of some of the bulk.. That’s the next step
  • The translate tool works like a charm, but there were some incompatibilities in the Groovy ModelBuilder that forced me to define some factories.
  • If you decide to jump into the world of non-XML POMs, be careful about integration with existing tools. m2eclipse isn’t going to read your Groovy POMs.
  • The only way I could get a multi-module build to work was when all of the POMs through the project had the same format. I also had to define relativePath to be ‘..’ or else the tool would flip out and try to parse Groovy POMs as XML from my ~/.m2/repository.

So, onward. Maybe in a day or so I’ll post the process for configuring pmaven-0.8-SNAPSHOT in Hudson. It worked like a charm. This thing really is a “Use at your own risk” tool at this point, the only way I could get this to work with my builds was to run mvnDebug and attach a debugger to it.