(Quick Reference) # 23.2 Build From Source and Run Tests Version: 3.2.8 ## 23.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 Once you have all the pre-requisite packages installed, the next step is to download the Grails source code, which is hosted at GitHub 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:
    git clone http://github.com/grails/grails-core.git
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. ### Creating a Grails installation If you look at the project structure, you’ll see that it doesn’t look much like a standard `GRAILS_HOME` 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 `grails` command to run, you’ll be using the version you just built. If you are using SDKMAN then that can also be used to work with this local installation via the following:
    sdk install grails dev /path/to/grails-core
Now you will have a dev version in your local which you can use to test your features. ### Running 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 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…​. ### Developing in IntelliJ IDEA You need to run the following gradle task:
    ./gradlew idea
Then open the project file which is generated in IDEA. Simple! ### Developing in STS / Eclipse You need to run the following gradle task:
    ./gradlew cleanEclipse eclipse
Before importing projects to STS do the following action: Edit grails-scripts/.classpath and remove the line "<classpathentry kind="src" path="../scripts"/>". 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 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 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:
    grails -debug run-app
| Quick Reference (hide)