This page explains how you can use a maven module being at the same time a groovy module. Like this you have full groovy editor support as auto completion and refactoring possibility. As an example the stk-migration module is taken. It contains the groovy migration scripts, while it also has to be available as a Maven module for the Webapp-Module at the same time.
The Ecplise version building upon is 3.6.
Install the groovy plugins
You need to install the groovy plugins as shown on the print screen:
- Groovy-Eclipse
- m2e Configuration for Groovy-Eclipse
The site for 3.6 is: http://dist.springsource.org/release/GRECLIPSE/e3.6/
This will take a while, go and drink a coffee
Converting the Module to a Groovy module
The module you want to convert to a groovy module can not be already installed as a project before the groovy plugins were installed. If you had the project already running, remove it complete again (also within file system), close Eclipse, and import it again. I had the problem that after converting the module to a groovy module, the module did never appear within the Webapp's 'Web App Libraries'. Make sure that after importing it again it shows up within your Webapp module in the 'Web App Libraries'.
Now convert the module to a Groovy module.
After converting it will look like this:
Make sure the module still shows up within your Webapp module in the 'Web App Libraries'.
Remove excludes and includes from Java build path
Go into the project properties, and remove from the 'Java Build path' -> 'source' all excludes and includes.
Result:
Attention: Seems that these excludes are removed from eclipse somethimes. I suspect the 'Maven -> Update Project Configuration. It appears by that no Java class which is deprected is not crossed anymore (as Content for example). Just remove them again... (I hope not again, and again...)
Make sure the module still shows up within your Webapp module in the 'Web App Libraries'.
Now you should be able to use the 'refactor' option in a groovy script. If you can refactor, everything went right.
3 Comments
Philipp Bärfuss
We should probably test the m2eclipse support for Groovy. Most likely we can configure everything in the pom and things will just work.
Christian Ringele
That would be really nice!
Samuel Schmitt
Installing "m2e Configuration for Groovy-Eclipse" mess up the pom.xml view, only the source view is available..