Skip to content

Developing Grails Apps in Eclipse

by Jeff

This was a post I was planning on linking to; a colleague of mine was going to write a post about it, but he hasn’t yet and I’ve just spent an extra hour trying to get this to work and am frustrated- and so here is the post you’ve all been waiting for.

There are lots of holes in the existing documentation about setting up eclipse to work with grails.

First off, you will want to generate groovy class files to a directory, like bin-groovy. It’s not just for debugging, it’s also for running unit tests. Running unit tests from eclipse is a lot faster than running them from the command line, because eclipse will generate the class files needed as you develop. It’s really nice to have.

Here’s where the fun starts- let’s assume you want to use a plugin. It’s a reasonable assumption, since there are so many cool plugins available. The first thing you need to know is where plugins download and install to. These go to a plugin directory in your .grails directory, which is normally in your home folder. You’ll need the jars from these plugins in your eclipse classpath, so you’ll need to unzip them and add them as external jars. Then, you’ll also need the source from those plugins in your classpath. For this, I added an External Class Folder to my Java Build Path- the folder was located in .grails/projects//classes.

While you’ll want to uncheck the Disable Groovy Compiler Generating Class File checkbox, you’ll want to enable the Disable Check Package Matches Source Directory, otherwise you’ll have a compiler error from resources.groovy.

Finally, add bin-groovy as a class folder to your java build path libraries tab.

This entry was a big help.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

7 Comments

  1. Yeah, it’s pretty frustrating, isn’t it? I use NetBeans when doing my own Groovy/Grails work, but I also work in Java for a client where all the development happens in Eclipse. I’d love to introduce Groovy unit tests to the project, but the Groovy support in Eclipse is weak enough it might just be a turn off. :(

    –Matt

    Sunday, May 10, 2009 at 4:09 am | Permalink
  2. Fanny Aenvie wrote:

    This is from the groovy-mailing-list:

    “Since a few weeks ago, one of SpringSource Eclipse experts is working
    almost full time on the Groovy Eclipse plugin.
    So we should see important progress pretty rapidly. ”

    There are some rumours that springsource
    will add groovy/grails-support to its STS.

    Sunday, May 10, 2009 at 2:23 pm | Permalink
  3. Jeff wrote:

    @Matt – Yeah that’s a tough call; the unit tests are nice and easy to write with grails, but it definitely takes a little extra work to get it going in eclipse, and if your decision is on the line… I get it.

    @Fanny – My company is a partner of SpringSource, and I’ve been hearing about this for the last few months. It could not come soon enough! You know it’s going to happen- Grails is an awesome framework after all. I love using it, except for the eclipse support. In fact I almost switched back to emacs, except their groovy modes are not any better. :-)

    Sunday, May 10, 2009 at 3:11 pm | Permalink
  4. KarlL wrote:

    Actually there is only one IDE exists with _very good_ Groovy/Grails support atm., which is IntelliJ IDEA.
    Bad points: propertary, gsp/groovy syntax coloring looks _really_ awful. There is a 30 day trial tho.

    Monday, May 11, 2009 at 3:26 pm | Permalink
  5. Daniel Serodio wrote:

    @Fanny, STS is not free, so unfortunately Grails support in STS won’t benefit the majority of the Grails community.

    Wednesday, May 13, 2009 at 9:43 pm | Permalink
  6. @Daniel: STS wasn’t free, but it is now – http://blog.springsource.com/2009/05/07/springsource-tool-suite-now-free/

    Wednesday, May 13, 2009 at 11:11 pm | Permalink
  7. Daniel Serodio wrote:

    @Matt, awesome news! I really hope the make the Grails support free-as-in-speech thou

    Friday, May 15, 2009 at 1:45 am | Permalink

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*