EDIT: Rewritten for GGTS 3.1.0. I recommend that you stop using GGTS 3.1.0.M1 for maven integration and move to the latest nightly or the final release. Many fixes are now in.
GGTS 3.1.0 now has support for mavenized grails projects. This feature requires m2e version 1.1 or later to be installed, which you can find on the dashboard. More information on working with and creating mavenized projects outside of GGTS can be found in the Grails docs.
Before importing a mavenized grails project, you must make sure of the following in your project and GGTS installation:
- Your project uses Grails version 2.1.1 and grails-maven-plugin version 2.1.1 or any later full release. Build snapshots will not work.
- You have the same version of Grails unzipped and installed in your GGTS instance.
- You have successfully run mvn compile from the command line before importing the project (this ensures that the grails project is in the correct shape and that all plugins are correctly installed and available.
- Due to GRAILS-9406, you may need to explicitly add groovy-all 1.8.8 as a dependency. Add this to your dependency section:
Code:<dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-all</artifactId> <version>1.8.8</version> <type>jar</type> </dependency>
- You have m2e (Eclipse plugin for maven) v1.1 or later installed in your GGTS.
- Your mavenized project uses the grails-app or the grails-plugin packaging. The war packaging will not work since it confuses WTP (Eclipse's Web Tools Project).
You can import a mavenized grails project using File -> Import... -> Existing Maven project wizard:
After importing your mavenized project, there may be a dialog asking you to convert the project to a Grails project:
You should click no. If you click yes, then your project will be imported without the Maven classpath container on it and you will likely have build errors. To get around this problem if you accidentally clicked yes, just run Maven -> Update project.
Also, your project may have errors if Grails dependency management has not been enabled. You can manually turn on Grails dependency management like this:
Once Grails dependency management has been enabled, you will notice that your mavenized project will have classpath containers both for Grails and for Maven:
This is OK. In GGTS, mavenized grails projects are treated using a hybrid of Grails and Maven features, and so grails-ide and m2e share responsibility to manage dependencies and provide functionality. It shouldn't be a surprise that, interacting with these kinds of projects will be different than interacting with a pure grails project.
First, here is a list of functionality known to work the same as before:
- Editor support, Groovy search, GSP search, Groovy refactoring and other editing commands
- The Project explorer view will show your project in a Grailsy way
- Grails commands that only manipulate project files such as create-domain-class, generate-views. You can execute these commands in any of the normal ways: the lightweight grails pop-up dialog, the grails command wizard, or a custom grails launch.
- Grails run-app and test-app will work as before including all debugging support
And there are some parts of your project that must be interacted with differently:
- Refresh dependencies/Project update: Don’t run Grails -> Refresh dependencies to update your classpath. Instead, run Maven -> Update project. Running refresh dependencies is disabled for mavenized projects since Maven manages the classpath.
- Installing plugins: you can open the Grails plugin manager, but you can’t install plugins from there. Instead, install plugins by adding the dependency to the plugin in your pom. Then run Maven -> Update project.
- Uninstalling/upgrading plugins: If you are uninstalling or upgrading a plugin:
- First update your pom.xml to reflect the new dependencies
- Run mvn clean on the project. This can be done either on the command line or inside of GGTS
- Run Maven -> Update project inside of GGTS.
This will give you a clean compile using the new plugins and removing any old ones.
- [B]Forked mode[B]: Note that GGTS will automatically run your Grails goals in forked mode even if you have explicit configuration in your pom otherwise. This is to avoid running out of permgen when Grails is run in-process.
If you have any problems or comments, please reply to this post. Also, be aware that most of the comments on the first page are outdated since they deal with an older version of these instructions.
Suggestions to improve these instructions are appreciated!