Last updated by 3 years ago

Page: GrailsDevEnvironment, Version:16

Setting up a Grails development environment

So, you'd like to delve into the Grails source code? Whatever reason you have for doing so, you first need to set yourself up so that you can easily run and debug with the source code version of Grails. Where to start?


You won't go far without some essential tools and libraries, but to be honest you probably already have all of them:

  • JDK (preferably 1.5+)
  • Git client

Downloading the Grails source code

Once you have all the pre-requisite packages installed, the next step is to download the Grails source code. The source code is hosted at in several different git repositories owned by the "grails" github user. To download the source using git, use the "git clone" command followed by the public URL of the repository you want to clone (download). For example, to clone the "grails-core" repository, run the following:

git clone

The above will create a "grails-core" directory in your current working directory populated with the project source and the git repository.

A zip distribution of each git tag (not including the git history) is also available on the "Downloads" tab of each github project.

Building and running

After you have made a change to Grails, how do you check that it has had the desired effect?

Create the required jars

Running "./gradlew libs" will create everything you need to run Grails. This target also skips running the extensive collection of Grails test classes (Grails' 1000+ tests can bring a single core processor to a grinding halt for some time).

Once the jars have been built, simply set GRAILS_HOME to the checkout directory and add the "bin" directory to your path.

Run the test suite

All you have to do to run the full suite of tests is:

./gradlew test
These will take a while (15-30 mins), so consider running individual tests using the command line. For example, to run the tests in src/test/org/codehaus/groovy/grails/orm/hibernate/MappingDslTests.groovy, run the following command:
./gradlew testSingleMappingDsl


To debug Grails run the Grails application using:

grails-debug <command>
and then connect to it remotely via the IDE. There should be an option for "remote debugging". Unless you modify the "grails-debug" script, you should connect to port 5005.

If you need to debug stuff that happens during application start-up, then you should modify the "grails-debug" script and change the "suspend" option from 'n' to 'y'.

You can read more about the JPDA Connection settings here:

It's also possible to get Eclipse to wait for incoming debugger connections and instead of using "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005" you could use this "-Xrunjdwp:transport=dt_socket,server=n,address=8000" (which assumes the Eclipse default port for remote java applications) Inside eclipse you create a new "Remote Java Application" launch configuration and change the connection type to "Standard (Socket Listen)" and click debug. This allows you to start a debugger session in eclipse and just leave it running and you're free to debug anything without having to keep remembering to relaunch a "Socket Attach" launch configuration. You might find it handy to have 2 scripts, one called "grails-debug", and another called "grails-debug-attach"