Setting Up Grails Projects in IntelliJ Idea

Since I’ve started doing some stuff in Grails lately I’ve virtually been forced to start looking for an alternative IDE. I’ve been an Eclipse guy for the last five years or so; ever since I got out of the JBuilder swamp. Unfortunately, the only IDE with decent support for Grails seems to be Idea (yes I tried NetBeans, but it was so dreadfully slow it wasn’t even funny). Now, even though it is possible to get it to work, it was very far from painless before it was all set up. Since I had problems, and since I had a really hard time finding information about this I figured I might as well share what I had to do to make it work.

Part of the problem was (I guess) that the projects were created outside of Idea, so they had to be imported. Another thing that turned out to be a big problem was that there are a number of inter-dependencies between the projects (set up as plugin dependencies in BuildConfig.groovy). Now, here are the steps I had to go through to make a multi-sub-project Grails project working in IntelliJ Idea:

  • First of all, create an empty top-level project (actively uncheck the ‘Create Module’ checkbox).
  • Then, for each of the sub projects, create a new module. The tricky part here is that it turned out that you need to select ‘Create from scratch..’ option and select the root directory of each Grails app as module directory (and name). Then, just select ‘Grails module’, and you’re done (for now)
  • Now we need to set up the build paths manually. For each of the modules that have local libraries included in the lib directory, that directory needs to be added manually as a jar directory dependency of that module. Make sure you check the ‘export’ checkbox as well, so that the binaries are included when you build and when if this module is referenced from another module (see below).
  • Next step is to manually remove and re-add each of the required plugins in each module. Be sure to re-add them one at a time; it didn’t work to add multiple plugins at once
  • Now if you have inter-dependencies between your modules (e.g. one app uses a plugin you made yourself, set up in BuildConfig.groovy), these need to be set up as module dependencies.
  • Finally we’re done. Now, double check the build path in the module settings window and make sure nothing is marked red. Try to build the project and you should be all set.

Obviously, the bad thing here is that it’s an incredible amount of work involved in getting everything up and working. The good thing however is that once you have it all set up it works really well. Code navigation and even debugging a remote Grails application works as a charm. That said, I’m still not comfortable with how Idea works. It just feels awkward somehow. I can’t wait for when the SpringSource guys get this working in Spring IDE so that I can get back to my IDE of choice.

This Post Has 3 Comments

    1. Tried Maia M1, and that didn’t work at all.

  1. Also, remember, grails has nice maven integration, so you can actually manage all from maven and bypass grails command line. This way it would integrate into any IDE that has Maven integration. IntelliJ is the best though, whether you use maven or grails import.

Leave a Reply

Close Menu