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/
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.
7 Comments
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
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.
@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.
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.
@Fanny, STS is not free, so unfortunately Grails support in STS won’t benefit the majority of the Grails community.
@Daniel: STS wasn’t free, but it is now – http://blog.springsource.com/2009/05/07/springsource-tool-suite-now-free/
@Matt, awesome news! I really hope the make the Grails support free-as-in-speech thou
Post a Comment