Grails is a great framework framework that enables rapid development with Java. Like with any framework however, you sometimes get stuck and need to take a look under the covers to solve a problem.
Today I was fighting with mapping a many-to-many relationship (a common occurrence in grails), and needed to figure out exactly why Grails and Hibernate were not doing what I expected. One of the great things about Java is that nearly the whole stack is open source so you can just step through the code to see what is going on, as long as you can find the code (and navigate through injected dependencies, but that is a different story).
Eclipse Maven plugins provide great tools to ‘Download Sources’ start viewing them immediately when you step into some third party library code. I am developing a Grails application on SpringSource Tool Suite (STS, v2.8.2 as of this writing), which is becoming the industry standard IDE for Spring and Grails based applications. Since Grails uses a Maven-like dependency management system, you would expect STS to be able to download sources for for any of the grails dependencies easily, right?
While this is a feature that might work for Grails 2.0, if you’re using Grails 1.3.7 then you will find a plugin named eclipse-scripts that enables you to download sources and then configure your projects so that STS can find the sources. Here’s what you do:
grails install-plugin eclipse-scripts grails compile grails download-sources-and-javadocs grails sts-link-sources-and-javadocs
Then restart STS and refresh your project. Now you can navigate into your project’s Grails Dependencies and view their source through STS!
Credit for creating the eclipse-scripts plugin to Lari Hotari