December 11, 2009

Is it possible to add groovy code to a java project?

Filed under: groovy, java, tip — michaelangela @ 3:47 am

Yes and it’s not so crazy either. The fact that you can swap the extension of a Java class to .groovy and continue to build with it in groovy is pretty cool, too.

Wabi Sabi Software: A Tutorial for Adding Groovy to a Java Project

The steps are basically
a) download and install the Groovy GDK
b) add a how-to-compile-groovy task to your Ant build.xml (the task is included in the GDK)
c) add the groovy-all.jar file to your library path
d) add the groovy-plugin to your Eclipse project
e) enable groovy-nature in your Eclipse project
f) write a Groovy class and use it.

Overall this should take no more than twenty minutes or so. One of the really cool things is that once you have a Groovy class you can use it from your Java classes just like any other class…your Java code has no idea its using a class written in Groovy.
Now lets look at the steps listed above in cookbook manner.

1 Comment »

  1. […] Filed under: groovy, maven — michaelangela @ 4:02 am So now that I know that Java and Groovy can coexist, the next question is can maven be used to compile a groovy […]

    Pingback by Building groovy projects with maven « Ramblings — December 11, 2009 @ 4:03 am

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com 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

Blog at WordPress.com.

%d bloggers like this: