I meant to post the details of the Groovy integration for Maven2 but, you see there was this gang of ninjas, right? They were like, “Prepare to defend yourself!” I was without nunchucks so I did my best to fend off the would be assasins. I found myself tied up in some dirty basement with a wood floor and inadequate lighting. Barely concious, I wriggled my way out of my bondage only to find the basement door was locked. I’m not sure what the attackers had in mind (they probably wanted the secret plans to my XML based warships or something) but I had to think fast. With a broken rubber band, a half stick of chewing gum and a 1976 bicentennial penny I was able to…
Are you buying any of this?? Because it’s true!! I can show you the war scars on my belly. Anyway, more to the point of Groovy Maven integration. I haven’t had time to play with my findings due to my bouts with ninjas and all so I’ll share what I have so far.
The most important piece of the puzzle is an enhancement to the Plexus compiler to support Groovy compilation. Once we have that then we can easily compile Groovy source without extra Ant scripting and such. I found such a compiler here. To get all of its compiling goodness on your spinning magnetic hard drive platters alls ya’ haff tuh do is (don’t you just hate it when some egg head says “alls yuh haff tuh do is….”?) install a subversion command line client and run this command:
svn co https://svn.codehaus.org/plexus/trunk/plexus-sandbox/plexus-components/ (command is wrapped for formatting quality) in a conveneint directory. It will pull down all of the source code and place it in a folder called plexus-compiler-groovyc. walk into that folder (I don’t mean physically walk into it, rather issue a change directory “cd” command to get there) and install the maven project therin. If you’re still new to Maven2 then the process for doing that is
mvn install. If you get a build failure then it’s not my fault. Yer on your own buddy! (However if you post a comment explaning your particular situation I’d be inclined to assist.) After the the project is installed you should be able to use the following snip in any Groovy Maven2 project:
<plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <compilerId>groovyc</compilerId> </configuration> <dependencies> <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-compiler-groovyc</artifactId> <version>1.5.1</version> </dependency> </dependencies> <extensions>true</extensions> </plugin>
Javalike Maven Plugin Tools
Now nothing could be more cool than getting Maven to compile Groovy code right? Wrong! What if I told you to go write a Maven plugin? "Aww man! I ain't tryin' ta' hear dat! I'd have to use stoopid Java syntax or clumsy Ant!", you say. Wrong! You can write a plugin today using pure groovy source. And guess what else? If you order now... err write it now... we'll have Maven dig into your Groovy source to pull out the annotations just the same way it would for Java source! "No way!", you say. "All the way!", we respond. There's a little known gem in the Mojo sandbox called Javalike Maven Plugin Tools that does the magic. Alls yuh haff tuh do is download the Maven2 sandbox (the whole sandbox including the sand), drill into the groovy-maven-tools folder (using your preferred power tool or command line console) and find the project. run the ol' "mvn install" command from that folder and viola! You can find detailed instructions for using and installing Mojo Sandbox plugins here on their site. (You really don't need the sand with the sandbox.)
That's cool for now. I'ma holla at'cha while you drop it like it's hot...