Skip to content

Building Maven Batch Compiler

Eric Milles edited this page Jul 1, 2024 · 27 revisions

This page details how to build and deploy the groovy-eclipse maven compiler artifacts.

The Projects

The interesting components are in the /extras folder. There are several projects located here:

  • groovy-eclipse-batch-builder : a set of ant scripts and configuration files used to build the groovy-eclipse-batch artifact; this artifact is an amalgamation of all jars required for compiling Groovy and Java code in Eclipse, including ecj (the Eclipse compiler for Java), the non-UI components of Groovy-Eclipse, the Groovy jars, and various required Eclipse bundles
  • groovy-eclipse-compiler : the compiler plugin itself
  • groovy-eclipse-compiler-tests : integration tests for groovy-eclipse-compiler/groovy-eclipse-batch
  • groovy-eclipse-maven-tests : a sample project that uses the groovy compiler plugins
  • groovy-eclipse-quickstart : an archetype project for groovy-eclipse-compiler/groovy-eclipse-batch
  • org.codehaus.groovy.m2eclipse : an eclipse plugin that provides integration between Groovy-Eclipse and m2eclipse (the Maven tooling for Eclipse)
  • Feature-org.codehaus.groovy.m2eclipse : an eclipse feature that is required for building and releasing the org.codehaus.groovy.m2eclipse plugin

Setting up an Eclipse Workspace

The build process relies on having an Eclipse workspace in which you successfully compile the Groovy Development Tools. The build will collect and jar-up compiled .class files from your workspace. See the project README.md for instructions on setting up a workspace.

Import the additional projects from the extras folder as 'existing projects' into your workspace. At least these 3 projects are required:

  • groovy-eclipse-batch-builder
  • groovy-eclipse-compiler
  • groovy-eclipse-compiler-tests

If you don't have m2e installed the groovy-eclipse-compiler project will have errors (because of missing dependencies). You can install m2e or ignore these errors if using command-line maven.

Version Numbers

Version numbers for groovy-eclipse-batch artifacts use a -01, -02, etc. suffix because it coincides with Groovy compiler releases, but sometimes off-cycle releases are required. groovy-eclipse-compiler once used this scheme to track groovy-eclipse releases but has been switched to semantic versioning as it has become stable.

New Groovy Version

When a new Groovy version comes out, first the Groovy Eclipse Compiler itself has to be updated. We assume this has already been done.

Now, to change the Groovy version in the batch compiler artifact, the easiest way is to use text search to find references to the old version number (e.g. 3.0.21) and replace them with the new one (e.g. 3.0.22).

These places need changing:

  • groovy-eclipse-batch-builder/build.properties (1 reference)
  • groovy-eclipse-compiler-tests/pom.xml: (2 references)

Building, Testing and Deploying

Preparation

Open groovy-eclipse-batch-builder/build.properties follow the comments and change any values as needed. Make sure to point to a fresh copy of Eclipse that is the same version as the one you targeted in your workspace. This is not strictly necessary, but is safer.

Make sure the e4XX matches your target version of Eclipse and that it is the folder containing the org.eclipse.jdt.core project you have imported into your workspace. This is crucial to make sure you will be packaging the bundle you actually compiled rather than something old and possibly broken.

Double-check your Groovy-Eclipse workspace. Perform a clean build. There should be no errors.

Check version numbers for groovy-eclipse-batch and groovy-eclipse-compiler. Make sure they are SNAPSHOT versions or RELEASE versions as appropriate for your intended build.

Build and test locally

If you wish to build from within Eclipse, right-click on groovy-eclipse-batch-builder/build.xml and choose Run As > Ant Build... and on the Targets tab check install.

To test the new batch compiler artifact, open groovy-eclipse-compiler-tests/pom.xml and set the groovy.rt.version and groovy.xx.version properties to the Groovy Runtime and groovy-batch-compiler versions respectively. You may need to adjust the Spock version in groovy-eclipse-compiler-tests/src/it/groovy-for-tests/pom.xml. And for the toolchain-aware test you will need a toolchains.xml at the root of your local repo that specifies a Java 11 toolchain. Then right-click on groovy-eclipse-compiler-tests and put integration-test for Goals. I usually run this step before building the batch compiler to see all tests fail due to missing artifact. Then when I run again, I have confidence that the new artifact is the one used. You can also run this project by itself to test other batch compiler versions from Maven Central or wherever.

To test the new compiler adapter artifact, open groovy-eclipse-compiler-tests/pom.xml and set the maven-compiler-adapter.version property. Then follow the execution steps from above.