From 110434ff60a14d2dfe8014459ffbea3ce7d6388b Mon Sep 17 00:00:00 2001 From: JohnPaulTaylorII Date: Fri, 18 Mar 2022 16:54:53 -0400 Subject: [fixes #3143] Maven+ECJ Agent Bootstrap * Adds AgentBootstrap, the actual bootstrapping agent * Adds MavenEcjBootstrapApp, the command line app for generating the appropriate files * Updates the build to package these correctly * Updates the documentation for setup/ecj --- .../templates/setup/ecj-in-maven-pom-example.xml | 81 ---------------------- website/templates/setup/ecj.html | 77 ++++++++++++++++---- website/templates/setup/maven.html | 6 ++ 3 files changed, 69 insertions(+), 95 deletions(-) delete mode 100644 website/templates/setup/ecj-in-maven-pom-example.xml (limited to 'website/templates') diff --git a/website/templates/setup/ecj-in-maven-pom-example.xml b/website/templates/setup/ecj-in-maven-pom-example.xml deleted file mode 100644 index 3bb10722..00000000 --- a/website/templates/setup/ecj-in-maven-pom-example.xml +++ /dev/null @@ -1,81 +0,0 @@ -<#noparse> - - - 4.0.0 - - org.projectlombok - eclipse-compiler-test - 1.0-SNAPSHOT - - - UTF-8 - - ${version} -<#noparse> - - - - - org.projectlombok - lombok - ${lombok.version} - provided - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - eclipse - 11 - - - - org.codehaus.plexus - plexus-compiler-eclipse - 2.8.6 - - - org.projectlombok - lombok - ${lombok.version} - - - - - org.apache.maven.plugins - maven-dependency-plugin - 3.1.1 - - - get-lombok - - copy - - - - - org.projectlombok - lombok - ${lombok.version} - jar - ${project.build.directory} - lombok.jar - - - - - - - - - - - diff --git a/website/templates/setup/ecj.html b/website/templates/setup/ecj.html index e01bc653..ae4979d6 100644 --- a/website/templates/setup/ecj.html +++ b/website/templates/setup/ecj.html @@ -1,32 +1,81 @@ <#import "_setup.html" as s> -<@s.scaffold title="ecj"> +<@s.scaffold title="ECJ"> <@s.introduction>

- ecj (the eclipse standalone compiler) is compatible with lombok. Use the following command line to enable lombok with ecj: + ECJ (the Eclipse standalone compiler) is compatible with Lombok. Use the following command line to enable Lombok with ECJ:

java -javaagent:lombok.jar=ECJ -jar ecj.jar -cp lombok.jar -source 1.8 (rest of arguments)

- You may have to add the following VM argument, if you're using an older version of lombok or java: + You may have to add the following VM argument, if you're using an older version of Lombok or Java:

-Xbootclasspath/p:lombok.jar

- If you're using a tool based on ecj, adding these VM arguments and adding lombok.jar to the classpath should work. + If you're using a tool based on ECJ, adding these VM arguments and adding lombok.jar to the classpath should work.

<@s.section title="Maven">

- It is possible to configure maven-compiler-plugin with maven-dependency-plugin and plexus-compiler-eclipse. + Lombok comes with a tiny bootstrap agent that can be included in your project to allow ECJ to easily work with Maven. + To create this agent, run: +

java -jar lombok.jar createMavenECJBootstrap -o /path/to/project/root

- Before the compile phase, you will have to set your MAVEN_OPTS environment variable to include the javaagent argument. In the example below, target is your ${r"${project.build.directory}"}. + The -o path should be the location of your pom.xml.

- Use the following commands in sequence to enable lombok with ecj in your Maven build: -

-# Make sure you've updated your pom as per this example.
-mvn clean dependency:copy@get-lombok
-set MAVEN_OPTS=-javaagent:target/lombok.jar=ECJ (or your OS's equivalent)
-mvn install
-set MAVEN_OPTS= (or your OS's equivalent)
+			This will create two files, .mvn/jvm.config and .mvn/lombok-bootstrap.jar. Maven will use these files
+			to activate the standard Lombok Java agent at the right time. These can be committed in source control for a portable build.
+		

+ You must also update your pom.xml to add Lombok as a dependency to the maven-compiler-plugin. A minimal example follows:

+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.projectlombok</groupId>
+  <artifactId>eclipse-compiler-test</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <lombok.version>${version}</lombok.version>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.projectlombok</groupId>
+      <artifactId>lombok</artifactId>
+      <version>${lombok.version}</version>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>3.10.1</version>
+          <configuration>
+            <compilerId>eclipse</compilerId>
+          </configuration>
+          <dependencies>
+            <dependency>
+              <groupId>org.codehaus.plexus</groupId>
+              <artifactId>plexus-compiler-eclipse</artifactId>
+              <version>2.11.1</version>
+            </dependency>
+            <dependency>
+              <groupId>org.projectlombok</groupId>
+              <artifactId>lombok</artifactId>
+              <version>${lombok.version}</version>
+            </dependency>
+          </dependencies>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>
 
-

+

diff --git a/website/templates/setup/maven.html b/website/templates/setup/maven.html index 0e28421f..f6c36822 100644 --- a/website/templates/setup/maven.html +++ b/website/templates/setup/maven.html @@ -37,6 +37,12 @@

+ + <@s.section title="Eclipse Compiler (ECJ/JDT)"> +

+ Check out the instructions on the ECJ page. +

+ <@s.section title="Delomboking: The Lombok Maven Plugin">

-- cgit