-
-
Notifications
You must be signed in to change notification settings - Fork 195
Groovy Eclipse Architecture
When working on the Groovy-Eclipse code base it is important to know about its broad architecture.
The best place to get an overview of the conceptual architecture is in this Blog article.
https://spring.io/blog/2009/07/30/a-groovier-eclipse-experience
After reading about the high-level concepts, you may still be left wondering about how and where these architectural concepts live in the code-base.
There are two kinds of 'patching' going on in the code base. By 'patching' we mean that there is a copy being taken of someone else's code, then this code is modified to make it somehow 'eclipse compatible' (i.e. as explained in the Blog article).
Two things are being patched:
-
The eclipse JDT compiler: it is patched to provide hooks so that JDT can compile both Groovy / Java code. To the rest of eclipse it makes it look like Groovy = Java.
-
The 'groovyc' commandline compiler: various bits of code from groovyc is called on by the JDT patch to parse and compiler groovy code. groovyc is patched to make this possible.
The patch consists of a 'feature' bundle and a 'plugin' bundle. The patch is specific to a particular version of eclipse. I.e. it targets a very specific eclipse version.
Care should be taken to compile / test / install always the right version of the patch according to the host eclipse version.
The patch is found on disk in directories:
- jdt-patch/e37
- jdt-patch/e43
- jdt-patch/e43-j8
- jdt-patch/e44
Directory names indicate the target version of Eclipse. 'e43-j8' targets eclipse 4.3 with the Java 8 patch installed.
All changes in this code must be properly marked with comments.
The 'org.eclipse.jdt.core' plugin is a a copy of an eclipse bundle with the same name. This bundle is the 'core' of the JDT compiler. We patch and replace it via a JDT feature patch.
Make changes in this code is very sensitive because it effectively replaces the Eclipse JDT compiler with our patched version.
It very mportant that any changes in this code do not alter the behavior of the eclipse Java compiler. Even when people are not using Groovy at all, the patched compiler is still used!
This is a 'companion' to 'org.eclipse.jdt.core'. It contains code that supports groovy compilation. All the code in here belongs to groovy eclipse, but it part of our JDT patch.
The 'Feature-org.eclipse.jdt' is patch feature. When installed into eclipse, it replaces the original 'org.eclipse.jdt.core' with our patched version of 'org.eclipse.jdt.core'
Some numbered bundles patch different versions of Groovy:
- org.codehaus.groovy21
- org.codehaus.groovy22
- org.codehaus.groovy23
Each one of these bundles contains a 'patch' of the 'groovyc' compiler for a specific version of groovyc.
The 'patch' works via a classloader trick. The 'groovy-all jar' containing the original groovyc is on the classpath. The code that needs patching is copied into a source folder and modified. The source folder's compiled code will be found by the classloader before searching the jar so it replaces the original code at runtime.
Changes in these plugins are sensitive becuse they could change the behavior of groovyc. When making changes here the intention should be to preserve the language semantics, but make the compiler 'play nice' with eclipse.
All changes in these files must be marked with comments '// GRECLIPSE'.
For details about the groovyc patching process refer to [Updating the groovy in groovy eclipse].