GroovyC Plugin For Maven2!

Today I got closer than ever to building the Groovyc plugin from the Codehaus Mojo sandbox. I started by looking at the old source that I had downloaded. I then started creating idea modules out of each maven project with the Idea plugin for Maven2. (That is a plugin that runs in Maven2 not a plugin that installs in Idea.) I fumbled around a bit then figured out what had me so hung up last time I tried building. The Groovyc plugin had a dependency on a plexus-compiler-groovyc jar that Maven couldn’t find anywhere. Getting to the point I was able to successfully build and install the Javalike tools plugin from the Codehaus Mojo sandbox. and finally install the Groovyc plugin! Then something really funny jumped out at me. Just see if you follow this…

I’m looking at the source for the Groovyc M2 plugin and it uses AntBuilder to do the compiles. Cool. Then I’m thinking, “Hey this plugin is written in Groovy! That’s pretty slick!” I don’t see the need for the stoopid plexus-compiler-groovyc jar that dumb Maven can’t find because it uses Antbuilder and it doesn’t try to extend Plexus. I comment out that idiotic dependency and viola! It builds with no problem! I install and try to use it on an example dummy Groovy Maven2 project that I generate via the Java archetype plugin. I keep getting ClassNotFoundExceptions from Maven as it tries to load/run the Groovyc plugin. I look in the target output folder for the Groovyc plugin project and see that there are no class files in it! D’oh! I think a little harder and figure out that there’s no way for Maven to compile the source for the project without, you guessed right… a Groovy compiler! “Ooooh! That’s why we need the dumb plexus-compiler-groovyc jar. Looking deeper in the docs I see that it’s supposed to be in some plexus sandbox repo or something. A little Googling and I find it. I run into all kinds of problems getting it because it’s just source on a svn repo and I’m not seeing how to check it out.

Long story shortened…
I finally get the plexus-compiler-groovyc.jar installed and get a real groovyc plugin built and installed. I’m too excited to fire it at my example Groovy/Maven2 project when I start getting java.lang.NoClassDefFoundError: org/apache/tools/ant/BuildLogger errors. Ok, I got all this far and guess what? Think about it. Do you see anything wrong with this picture? I’ll spell it out.

What’s wrong?
Here’s the problem:

  • I put in all that effort trying to build a groovy compiler plugin to compile groovy projects.
  • The main thing that always stopped me from being able to build and install the plugin was a compiler to compile the project.
  • The plugin project was a Maven2 project so I needed, found, built, and installed a Maven2 Groovy Compiler so I could build a Maven2 compiler plugin which is still broken!

It seems like the sandbox plugin was an academic excercise or a means of testing the groovy javalike maven tools plugin which would allow you to write plugins in groovy. The whole time I struggled for a compiler my answer was right in front of me. I have a Maven2 groovy compiler that I have succesfully used to build a Maven2 project. I completely missed that fact in my dilligence to build the Antbuilder based plugin that still doesn’t work. So in the end there’s good news and there’s bad news. The bad news is how I still can’t get the compiler plugin to work. The better news is that I’ve found and built the source for the Plexus compiler extension for Maven2 that i wanted all along. I’m going to try to squeeze some more time in and play with everything some more before I post the details on how to best build your Maven2 Groovy projects. I’m still not certain which way is best to go, the AntBuilder based plugin or the Plexus compiler extension. Either way is far better than my ealier solution of embedding Ant code in your M2 pom. Get at me if ya’ feelin me…

(The author does not expect to be physically felt or touched by any readers. Instead the idea is for readers to “get at” or leave comments for the author if they are “feelin'” or in agreement with the above text. Apologies to those who got lost in the context.)

2 thoughts on “GroovyC Plugin For Maven2!

  1. What I want to do on my blog, is every few hours take the oldest post and move it to the
    front of the queue, all automatically. Anyone know if there is a plugin that can do this or
    a simple way to set up another plugin to do this (use my own feed perhaps)?

  2. I’m a little confused. You’re posting on my GroovyC plugin article and this doesn’t appear to be related to Groovy or Maven2, unless I’m misunderstanding. Are you asking if there’s a plugin that would allow you to arrange the order of posts? IF so, then sorry but you got the wrong guy. I’m no WordPress expert.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s