Idea 8.1 & Grails 1.1

I’ve been working with Grails again lately after not using it for a while. Last time I was using Grails was a pre-1.0 release about a year ago. Even then it was an extremely productive framework, but it was rough around the edges.

The main obstacle I saw was that exception messages and stack traces were not descriptive of the root problem. It wasn’t that the error messages were poorly written, but the error that was reported wasn’t near the root cause of the problem. The reported error was a far-removed side effect of the actual problem. If you had messed up the definition of your GORM domain class, the application may start up fine and complain that some dynamic save method was undefined for the domain class when you tried to use it. You then had to do a good deal of trial and error until you isolated what change caused the problem. Having a robust set of unit tests for your application helped, but it still took a while to diagnose the problem.

I’ve been using Grails 1.1 betas lately, and it looks like the error reporting has gotten much better. When I’ve gotten errors, it was usually pretty clear what the cause was.

Officially, IDEA only supports Grails 1.0, but it’s working fine for me with some tweaks. Here’s what I did:

  • Created the Grails 1.1 project outside of IDEA, using the grails command (not MVN plugin)
  • Redefine GROOVY and GRAILS global libraries in IDEA to point to the latest versions of each
  • Imported the existing Grails project into IDEA
  • After installing some Grails plugins (specifically, the google-chart plugin), I found that they weren’t on the classpath and the grails launcher no longer worked. Apparently Grails 1.1 moved where the plugins are stored and IDEA hasn’t been updated for this yet. To get around it, I added <home dir>/.grails/1.1/projects/<my project> to the module’s content root for my project, and added the plugin’s source directory (plugins/google-chart-0.4.8/src/groovy in my case) as a source folder within the added content root.

The grails app launcher is working for me, and I’m not getting the compile problems I was getting before.

This entry was posted in General, Grails and tagged , . Bookmark the permalink.

3 Responses to Idea 8.1 & Grails 1.1

  1. Alex Li says:

    What kind of compilation problems did you run into before? I am currently using IDEA 8.1.3 #9886 with its JetGroovy plugin, Grails 1.1.1. I created a Grails module which depends on existing Java modules in the same project. However, when I try to run the Grails application (run-app), the depending Java modules jars are not on the classpath, thus my Java code can’t compile in groovyc steps.

    Do you have any ideas? Thanks

  2. ron says:

    All of my code is within the Grails app module, so can’t say I’ve come across that.
    One thing that comes to mind is whether IDEA is generating a jar file for your Java module, and placing it within the grails app.. IDEA probably delegates to the ‘grails run-app’ command, and probably requires all of the classes/jars to be available on the filesystem in the standard grails app structure.

  3. Andy E says:

    @Alex Li: I am having the same problem. Our grails app depends on two external Java Modules as well. I have set up the grail module to depend on those two external modules, but the minute I try to build or run the app, I get a compiler error stating it cannot find the classes in those external modules.

    The only way I have round to get around it is to JAR those modules up and stick them in the LIB directory. Kind of a pain if you ask me.

Leave a Reply

Your email address will not be published. Required fields are marked *