Switching dialog in Eclipse Preferences
The first thing which came to my mind was to create two separate workspaces - one for Groovy 1.7 projects and the other for 1.8 ones. I hoped the settings are per workspace and this will be enough but the compiler setting is set globally for whole Eclipse installation. Nevertheless, using separate workspaces gives you a good overview, which version projects use and in my opinion you should not mix 1.7 and 1.8 projects unless you want to spend a day confirming "The source cannot be build because some-lib is not compatible with Groovy 1.X version" message dialog. Spock framework libs could be especially annoying because they have two separate versions for 1.7 and 1.8 which are not compatible with the other one. The other way is to keep project in one workspace and always close the projects causing the troubles which is quite cumbersome.
As for now we should have two workspaces - one for each bunch of projects for particular Groovy version. But this doesn't fix our problem. What we need are two configuration folders. The best way to create them is to launch your Eclipse, switch to the 1.8 compiler and close it. Then go to your Eclipse installation folder and duplicate whole configuration folder to the e.g. configuration18. To switch the original configuration back to 1.7 compiler follow these steps from the switching guide
- Go to eclipse/configuration/org.eclipse.equinox.simpleconfigurator
- Make a backup copy of bundles.info
- Open bundles.info in a text editor
- Find the line for org.codehaus.groovy_1.8 and delete (thus leaving the 1.7 compiler enabled)
Do this for the configuration folder only and leave the configuration18 as it is. The last mile is to launch the Eclipse with given configuration using the command line arguments
eclipse -configuration configuration18 -data workspace18
Specifying the workspace folder is optional. You will probably want to wrap up it as a BAT file or a shell alias/script. This launcher will use the 1.8 compiler. If you want to run 1.7 one you just use the standard one.