This is an automated email from the ASF dual-hosted git repository.

mattcasters pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/main by this push:
     new bcbdec0581 Issue #8406 : Make ECJ compilation work with Debian/Ubuntu 
Maven (#8407)
bcbdec0581 is described below

commit bcbdec058199643ba8feeec79105f88c49ea6258
Author: Matt Casters <[email protected]>
AuthorDate: Wed Sep 16 09:35:00 2026 +0200

    Issue #8406 : Make ECJ compilation work with Debian/Ubuntu Maven (#8407)
    
    Debian/Ubuntu Maven uses Sisu 0.3.x whose shaded ASM only reads class
    files through Java 14, so plexus-compiler-eclipse 2.17.0 is never
    registered. Register compilerId=eclipse via a Plexus descriptor and
    attach the Lombok ECJ agent on every module so single-module builds work.
---
 .gitignore                                         |   2 +
 .mvn/plexus-eclipse-hint.jar                       | Bin 0 -> 1408 bytes
 .../META-INF/plexus/components.xml                 |  34 +++++++
 pom.xml                                            | 113 ++++++++++++---------
 4 files changed, 103 insertions(+), 46 deletions(-)

diff --git a/.gitignore b/.gitignore
index 752dd3ff69..704edd57e1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,6 +13,8 @@ pom.xml.releaseBackup
 bin
 *.class
 *.jar
+# Tiny Plexus descriptor so Debian/Ubuntu Maven can find compilerId=eclipse.
+!.mvn/plexus-eclipse-hint.jar
 *.war
 *.ear
 .DS_Store
diff --git a/.mvn/plexus-eclipse-hint.jar b/.mvn/plexus-eclipse-hint.jar
new file mode 100644
index 0000000000..bf0e4f1979
Binary files /dev/null and b/.mvn/plexus-eclipse-hint.jar differ
diff --git a/.mvn/plexus-eclipse-hint/META-INF/plexus/components.xml 
b/.mvn/plexus-eclipse-hint/META-INF/plexus/components.xml
new file mode 100644
index 0000000000..98eb02c1bd
--- /dev/null
+++ b/.mvn/plexus-eclipse-hint/META-INF/plexus/components.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~       http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<!--
+  Debian/Ubuntu Maven (3.8.7 on 24.04, 3.9.12 on 26.04) uses distro Sisu
+  0.3.4/0.3.5. That Sisu's shaded ASM only reads class files through Java 14,
+  so it cannot index plexus-compiler-eclipse 2.17.0 (Java 17, @Named). The
+  compiler class itself runs fine on JDK 21; only the scan fails. This Plexus
+  descriptor registers compilerId=eclipse without ASM-indexing that class.
+-->
+<component-set>
+  <components>
+    <component>
+      <role>org.codehaus.plexus.compiler.Compiler</role>
+      <role-hint>eclipse</role-hint>
+      
<implementation>org.codehaus.plexus.compiler.eclipse.EclipseJavaCompiler</implementation>
+      <isolated-realm>false</isolated-realm>
+    </component>
+  </components>
+</component-set>
diff --git a/pom.xml b/pom.xml
index 5150c19980..054fc6116c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -136,6 +136,7 @@
         <license.licenseFile>LICENSE.txt</license.licenseFile>
         <license.licenseName>apache_v2</license.licenseName>
         <license.organizationName>Apache</license.organizationName>
+        <lombok.ecj.agent.skip>false</lombok.ecj.agent.skip>
         <lombok.version>1.18.46</lombok.version>
         <maven-failsafe-plugin.forkCount>1</maven-failsafe-plugin.forkCount>
         
<maven-failsafe-plugin.reuseForks>true</maven-failsafe-plugin.reuseForks>
@@ -394,42 +395,25 @@
                     </execution>
                 </executions>
             </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-dependency-plugin</artifactId>
-                <inherited>false</inherited>
-                <executions>
-                    <execution>
-                        <id>ensure-lombok-ecj-agent-jar</id>
-                        <goals>
-                            <goal>copy</goal>
-                        </goals>
-                        <phase>validate</phase>
-                        <configuration>
-                            <artifactItems>
-                                <artifactItem>
-                                    <groupId>org.projectlombok</groupId>
-                                    <artifactId>lombok</artifactId>
-                                    <version>${lombok.version}</version>
-                                </artifactItem>
-                            </artifactItems>
-                            
<outputDirectory>${maven.multiModuleProjectDirectory}/.mvn</outputDirectory>
-                            <overWriteIfNewer>false</overWriteIfNewer>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
             <plugin>
                 <groupId>org.codehaus.gmavenplus</groupId>
                 <artifactId>gmavenplus-plugin</artifactId>
                 <version>${gmavenplus-plugin.version}</version>
-                <inherited>false</inherited>
+                <!-- inherited so `cd <module> && mvn` and `-pl <module>` 
still attach
+                     Lombok and materialize the Eclipse compiler Plexus 
descriptor.
+                     Debian/Ubuntu Maven never indexes plexus-compiler-eclipse 
2.17.0
+                     (Sisu 0.3.x ASM stops at Java 14 class files). -->
                 <dependencies>
                     <dependency>
                         <groupId>org.apache.groovy</groupId>
                         <artifactId>groovy</artifactId>
                         <version>${groovy.version}</version>
                     </dependency>
+                    <dependency>
+                        <groupId>org.projectlombok</groupId>
+                        <artifactId>lombok</artifactId>
+                        <version>${lombok.version}</version>
+                    </dependency>
                 </dependencies>
                 <executions>
                     <execution>
@@ -439,35 +423,61 @@
                         </goals>
                         <phase>validate</phase>
                         <configuration>
-                            
<skipScriptExecution>${lombok.ecj.agent.attached}</skipScriptExecution>
+                            
<skipScriptExecution>${lombok.ecj.agent.skip}</skipScriptExecution>
                             <scripts>
                                 <script><![CDATA[
 import com.sun.tools.attach.VirtualMachine
 import java.nio.file.Files
 import java.nio.file.StandardCopyOption
+import java.util.zip.ZipEntry
+import java.util.zip.ZipOutputStream
+
+def projectDir = new 
File(System.getProperty('maven.multiModuleProjectDirectory'))
+synchronized (System.getProperties()) {
+    def hintXml = new File(projectDir, 
'.mvn/plexus-eclipse-hint/META-INF/plexus/components.xml')
+    def hintJar = new File(projectDir, '.mvn/plexus-eclipse-hint.jar')
+    if (hintXml.isFile() && (!hintJar.isFile() || hintJar.lastModified() < 
hintXml.lastModified())) {
+        hintJar.withOutputStream { fos ->
+            def zos = new ZipOutputStream(fos)
+            zos.putNextEntry(new ZipEntry('META-INF/plexus/components.xml'))
+            hintXml.withInputStream { it.transferTo(zos) }
+            zos.closeEntry()
+            zos.close()
+        }
+        log.info('Wrote Eclipse compiler Plexus descriptor jar: ' + hintJar)
+    }
 
-if (System.getProperty('lombok.ecj.agent.skip') != 'true') {
-    synchronized (System.getProperties()) {
-        if (System.getProperty('lombok.ecj.agent.attached') == null) {
-            def lombokJar = new 
File(System.getProperty('maven.multiModuleProjectDirectory'), '.mvn/lombok-' + 
project.properties['lombok.version'] + '.jar')
-            if (!lombokJar.isFile() || lombokJar.length() < 1000000L) {
-                throw new IllegalStateException('Lombok jar missing or 
incomplete for the ECJ agent attach, expected ' + lombokJar)
+    if (System.getProperty('lombok.ecj.agent.skip') != 'true'
+            && System.getProperty('lombok.ecj.agent.attached') == null) {
+        def lombokJar = null
+        try {
+            def loc = 
Class.forName('lombok.launch.Agent').protectionDomain.codeSource.location
+            if (loc != null && loc.protocol == 'file') {
+                lombokJar = new File(loc.toURI())
             }
-            def agentJar = Files.createTempFile('lombok-ecj-agent-', 
'.jar').toFile()
-            agentJar.deleteOnExit()
-            Files.copy(lombokJar.toPath(), agentJar.toPath(), 
StandardCopyOption.REPLACE_EXISTING)
+        } catch (ClassNotFoundException ignored) {
+            // fall through to .mvn/lombok-*.jar
+        }
+        if (lombokJar == null || !lombokJar.isFile()) {
+            lombokJar = new File(projectDir, '.mvn/lombok-' + 
project.properties['lombok.version'] + '.jar')
+        }
+        if (!lombokJar.isFile() || lombokJar.length() < 1000000L) {
+            throw new IllegalStateException('Lombok jar missing or incomplete 
for the ECJ agent attach, expected ' + lombokJar)
+        }
+        def agentJar = Files.createTempFile('lombok-ecj-agent-', 
'.jar').toFile()
+        agentJar.deleteOnExit()
+        Files.copy(lombokJar.toPath(), agentJar.toPath(), 
StandardCopyOption.REPLACE_EXISTING)
+        try {
+            def vm = 
VirtualMachine.attach(String.valueOf(ProcessHandle.current().pid()))
             try {
-                def vm = 
VirtualMachine.attach(String.valueOf(ProcessHandle.current().pid()))
-                try {
-                    vm.loadAgent(agentJar.absolutePath, 'ECJ')
-                } finally {
-                    vm.detach()
-                }
-                System.setProperty('lombok.ecj.agent.attached', 'true')
-                log.info('Lombok ECJ agent attached (source: ' + lombokJar + 
')')
-            } catch (Throwable t) {
-                throw new IllegalStateException('Unable to self-attach the 
Lombok ECJ agent, ensure -Djdk.attach.allowAttachSelf=true is in 
.mvn/jvm.config and the environment allows self-attach, or skip it with 
-Dlombok.ecj.agent.skip=true', t)
+                vm.loadAgent(agentJar.absolutePath, 'ECJ')
+            } finally {
+                vm.detach()
             }
+            System.setProperty('lombok.ecj.agent.attached', 'true')
+            log.info('Lombok ECJ agent attached (source: ' + lombokJar + ')')
+        } catch (Throwable t) {
+            throw new IllegalStateException('Unable to self-attach the Lombok 
ECJ agent, ensure -Djdk.attach.allowAttachSelf=true is in .mvn/jvm.config and 
the environment allows self-attach, or skip it with 
-Dlombok.ecj.agent.skip=true', t)
         }
     }
 }
@@ -498,6 +508,16 @@ if (System.getProperty('lombok.ecj.agent.skip') != 'true') 
{
                         <artifactId>lombok</artifactId>
                         <version>${lombok.version}</version>
                     </dependency>
+                    <!-- Plexus XML registration of compilerId=eclipse. 
Required for
+                         Debian/Ubuntu Maven, whose Sisu 0.3.x cannot 
ASM-index the
+                         Java 17 EclipseJavaCompiler class. See 
.mvn/plexus-eclipse-hint/. -->
+                    <dependency>
+                        <groupId>org.apache.hop</groupId>
+                        <artifactId>plexus-eclipse-hint</artifactId>
+                        <version>1.0</version>
+                        <scope>system</scope>
+                        
<systemPath>${maven.multiModuleProjectDirectory}/.mvn/plexus-eclipse-hint.jar</systemPath>
+                    </dependency>
                 </dependencies>
             </plugin>
             <plugin>
@@ -549,6 +569,7 @@ if (System.getProperty('lombok.ecj.agent.skip') != 'true') {
                         <exclude>.dockerignore</exclude>
                         <!-- symlink alias of AGENTS.md (header lives on the 
target) -->
                         <exclude>CLAUDE.md</exclude>
+                        <exclude>.mvn/plexus-eclipse-hint.jar</exclude>
 
                         <!-- Unit Test Exclusions -->
                         <exclude>**/test/**/*.txt</exclude>

Reply via email to