|Table of Contents|
Building Groovy Eclipse in Eclipse
Below is a step-by-step list of instructions that takes you through the process of setting up an Eclipse environment for building the Groovy-Eclipse plugin. These instructions were written while going through the process on a Mac OS Lion machine. Except for choosing an Eclipse and installing git, the process is similar no matter which OS and architecture you are using
These instructions are meant for Eclipse 3.7 (Indigo) or Eclipse 4.2 (Juno).
Download and Install Eclipse
Download and unzip Eclipse for RCP/Plug-in Developers from http://eclipse.org/downloads. Choose the appropriate version for your architecture.
Ubuntu note: Don't install Eclipse from the Ubuntu repositories download it manually from eclipse.org instead.
Groovy-Eclipse is available from github. To work with github, you need to have git installed on your machine. Github has some good documentation for a gentle introduction into git and it explains how to install the command line tools.
Install eGit (Optional)
eGit is the Eclipse tool support for working with git source code repositories. This tooling is helpful for running git operations inside of Eclipse. Things like viewing history and diffs are much more easily done than with command line tools. Also, having good integration with Eclipse makes simple operations like committing, pushing and, pulling possible without leaving the IDE. However, for more complex operations like rebasing and complex merges are typically more easily done on the command line.
To install eGit, use the following update site:
Eclipse 4.3 (Kepler) - http://download.eclipse.org/releases/kepler
Eclipse 4.2 (Juno) - http://download.eclipse.org/releases/juno
Choose to install eGit (the visual tooling for git) and jGit (a java-based implementation of git),
No need to restart.
Some of the projects contain Groovy code, so we need to have Groovy support installed.
Preferably, the latest version of Groovy Eclipse should be installed, which can be obtained from the update site for the latest snapshot. Now, restart.
See getting a developer build for more information on where to get the development snapshots.
Import Groovy-Eclipse source code into your workspace (the simple way)
The canonical Groovy-Eclipse repository is located at github. The easiest way to import the source code into your workspace is to use the following Groovy-Eclipse team project set groovy-eclipse-e42-project-set.psf for Eclipse Juno, or groovy-eclipse-e43-project-set.psf for Eclipse Kepler. To use, go to File -> Import... -> Team project set and paste the URL. Importing the team project set will take a long time since the entire repository needs to be cloned.
Import Groovy-Eclipse source code into your workspace (the complicated way)
You can ignore this section if you imported the source code the simple way. This section provides a more detailed description of which projects to import and how to do it if you are not using the psf file above.
If you are running git from the command line, use the following command to clone the repository:
Have a cup of coffee or a beer while the project is cloned.
After cloning is complete, you must import the projects into your Eclipse workspace. Click on File → Import → Existing projects into workspace. Choose the top-level git repository folder and search for all projects recursively. You will see something like this, with many, many projects available for import:
Or, you can clone from inside of eGit. Use the git repository url above and follow the directions on the eGit documentation.
You do not need to import all projects, and some projects conflict with each other. Here are some suggestions on what to import:
- IMPORTANT: there are multiple org.eclipse.jdt.core projects. These projects contain the patched Eclipse Java compiler and are specific to a single version of Eclipse. Only import the single project that matches your Eclipse level (e.g., E36, E37, or E42). To determine which project is appropriate for your eclipse level, look at the path to each of these projects, and you will see a segment like: jdt-patch/e42. Match your eclipse level to the path. If you do not follow this step, you will see compile errors in the imported projects.
- The projects org.codehaus.groovy16, org.codehaus.groovy18, and org.codehaus.groovy20 projects contain the groovy 1.6, 1.8, and 2.0 compilers respectively. The org.codehaus.groovy project contains the groovy 1.7 compiler. It is not necessary to import all of these projects. If you import more than one compiler project, then the latest one will take precedence over the earlier ones.
- The org.codehaus.groovy.m2eclipse project requires m2eclipse to be installed in your target Eclipse. If m2eclipse is not available, there will be compile errors. This project provides maven integration when running in an Eclipse workbench. You do not need to import this project unless you intend to work on maven integration.
- Any project that contains the word test contains unit tests. It is recommended to import these projects.
- Any project prefixed with Feature as well as the Site Groovy does not contain code and can be ignored unless you know that you need it.
- Any project prefixed with groovy-eclipse- is part of the maven compiler plugin for groovy-eclipse. You only need to import these projects if you plan on working on the maven support.
- The org.codehaus.groovy.eclipse.pluginbuilder project contains the releng code to build Groovy-Eclipse and publish the update site.
Run the tests
Optionally, you may want to run the tests. Do Run As->JUnit plugin test on org.codehause.groovy.alltests.
Note: There are two separate sets of tests in alltests plugin:
- AllGroovyTests.java — the UI tests (content assist, navigation, refactoring, etc) takes ~35-45 minutes to run
- GroovyJDTTests.java — the core tests (parser, compiler integration, type inferencing, searching, etc) takes ~10-15 minutes to run
At the time when I wrote this, *running both test suites at once resulted in a number of test failures* in the GroovyJDTTests suite. Running both the suites separately I got no such failures.
Note: If you get an Out of Memory Error like this:
java.lang.OutOfMemoryError: PermGen space at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) at java.lang.ClassLoader.defineClass(ClassLoader.java:616) ...
You can increase the size of PermGen space in "Run As -> Run Configurations"
Add this to VMArguments: