22.2 Build From Source and Run Tests - Reference Documentation
Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith, Lari Hotari
Version: 3.0.11
22.2 Build From Source and Run Tests
If you're interested in contributing fixes and features to any part of grails, you will have to learn how to get hold of the project's source, build it and test it with your own applications. Before you start, make sure you have:- A JDK (7 or above)
- A git client
git clone http://github.com/grails/grails-core.git
Creating a Grails installation
If you look at the project structure, you'll see that it doesn't look much like a standardGRAILS_HOME
installation. But, it's very simple to turn it into one. Just run this from the root directory of the project:./gradlew install
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 grails
command to run, you'll be using the version you just built.If you are using gvm
then that can also be used to work with this local installation via the following:gvm install grails dev /path/to/grails-core
Running the test suite
All you have to do to run the full suite of tests is:./gradlew test
BinaryPluginSpec
simply execute the following command:
./gradlew :grails-core:test --tests *.BinaryPluginSpec
Developing in IntelliJ IDEA
You need to run the following gradle task:./gradlew idea
Developing in STS / Eclipse
You need to run the following gradle task:./gradlew cleanEclipse eclipse
- Edit grails-scripts/.classpath and remove the line "<classpathentry kind="src" path="../scripts"/>".
- Add the springloaded-core JAR file in $GRAILS_HOME/lib/org.springsource.springloaded/springloaded-core/jars to grails-core's classpath.
- Remove "src/test/groovy" from grails-plugin-testing's source path GRECLIPSE-1067
- 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 "<classpathentry kind="src" path="../scripts"/>"). 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 profile.xml). 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.
Debugging Grails or a Grails application
To enable debugging, run:grails --debug-fork run-app
--debug-fork
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:grails -debug run-app