A JDK (7 or above)
Once you have all the pre-requisite packages installed, the next step is to download the Grails source code, which is hosted at in several repositories owned by the "grails" GitHub user. This is a simple case of cloning the repository you’re interested in. For example, to get the core framework run:
This will create a "grails-core" directory in your current working directory containing all the project source files. The next step is to get a Grails installation from the source.
If you look at the project structure, you’ll see that it doesn’t look much like a standard installation. But, it’s very simple to turn it into one. Just run this from the root directory of the project:
./gradlew install
This will fetch all the standard dependencies required by Grails and then build a GRAILS_HOME
installation. Note that this target skips the extensive collection of Grails test classes, which can take some time to complete.
Once the above command has finished, simply set the GRAILS_HOME
environment variable to the checkout directory and add the "bin" directory to your path. When you next type command to run, you’ll be using the version you just built.
If you are using then that can also be used to work with this local installation via the following:
sdk install grails dev /path/to/grails-core
All you have to do to run the full suite of tests is:
These will take a while (15-30 mins), so consider running individual tests using the command line. For example, to run the test spec BinaryPluginSpec
simply execute the following command:
./gradlew :grails-core:test --tests *.BinaryPluginSpec
Note that you need to specify the sub-project that the test case resides in, because the top-level "test" target won’t work….
You need to run the following gradle task:
Then open the project file which is generated in IDEA. Simple!
You need to run the following gradle task:
Before importing projects to STS do the following action:
- Edit grails-scripts/.classpath and remove the line "
".
Use "Import→General→Existing Projects into Workspace" to import all projects to STS. There will be a few build errors. To fix them do the following:
Add the jsp-api JAR file in $GRAILS_HOME/lib/javax.servlet.jsp/jsp-api/jars to the classpath of grails-web
Fix the source path of grails-scripts. Add linked source folder linking to "../scripts". If you get build errors in grails-scripts, do "../gradlew cleanEclipse eclipse" in that directory and edit the .classpath file again (remove the line "
"). Remove possible empty "scripts" directory under grails-scripts if you are not able to add the linked folder. Do a clean build for the whole workspace.
To use Eclipse GIT scm team provider: Select all projects (except "Servers") in the navigation and right click → Team → Share project (not "Share projects"). Choose "Git". Then check "Use or create repository in parent folder of project" and click "Finish".
Get the recommended code style settings from the mailing list thread (final style not decided yet, currently ). Import the code style xml file to STS in Window→Preferences→Java→Code Style→Formatter→Import . Grails code uses spaces instead of tabs for indenting.
To enable debugging, run:
grails run-app --debug-jvm
By default Grails forks a JVM to run the application in. The -debug-jvm
argument causes the debugger to be associated with the forked JVM. In order to instead attach the debugger to the build system which is going to fork the JVM use the -debug
option: