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

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


The following commit(s) were added to refs/heads/main by this push:
     new b98b2ef6d2ff Fix flaky parallel build failure in camel-test-infra-all 
jandex indexing (#21985)
b98b2ef6d2ff is described below

commit b98b2ef6d2ffca10ae861ac1539a1aa592985733
Author: Guillaume Nodet <[email protected]>
AuthorDate: Fri Mar 13 13:17:51 2026 +0100

    Fix flaky parallel build failure in camel-test-infra-all jandex indexing 
(#21985)
    
    In parallel reactor builds (SmartBuilder), Maven resolves reactor
    dependencies to target/classes directories instead of JAR files.
    The jandex-maven-plugin's ArchiveScanner only accepts files (JARs),
    causing an IllegalStateException: "Archive ... is not a file".
    
    Fix by:
    - Moving jandex and metadata generation phases from generate-resources
      to prepare-package, ensuring reactor dependencies have JARs available
    - Making classExistsInDependency handle both JARs and directories
      for reactor-resolved artifacts, using exact class path matching
      instead of simple name substring matching
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
---
 test-infra/camel-test-infra-all/pom.xml              |  4 ++--
 .../CamelTestInfraGenerateMetadataMojo.java          | 20 +++++++-------------
 2 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/test-infra/camel-test-infra-all/pom.xml 
b/test-infra/camel-test-infra-all/pom.xml
index b47468b269c3..784542ed05cb 100644
--- a/test-infra/camel-test-infra-all/pom.xml
+++ b/test-infra/camel-test-infra-all/pom.xml
@@ -305,7 +305,7 @@
                         <goals>
                             <goal>jandex</goal>
                         </goals>
-                        <phase>generate-resources</phase>
+                        <phase>prepare-package</phase>
                         <configuration>
                             <fileSets>
                                 <fileSet>
@@ -611,7 +611,7 @@
                         <goals>
                             <goal>test-infra-generate-metadata</goal>
                         </goals>
-                        <phase>generate-resources</phase>
+                        <phase>prepare-package</phase>
                     </execution>
                 </executions>
             </plugin>
diff --git 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/CamelTestInfraGenerateMetadataMojo.java
 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/CamelTestInfraGenerateMetadataMojo.java
index 90a590364580..bd285f9e2cb7 100644
--- 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/CamelTestInfraGenerateMetadataMojo.java
+++ 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/CamelTestInfraGenerateMetadataMojo.java
@@ -20,11 +20,9 @@ import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Enumeration;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
-import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 
 import javax.inject.Inject;
@@ -83,8 +81,8 @@ public class CamelTestInfraGenerateMetadataMojo extends 
AbstractGeneratorMojo {
             try {
                 // Search for target class in the project transitive artifacts 
to retrieve maven coordinates
                 for (Artifact artifact : project.getArtifacts()) {
-                    if (classExistsInJarFile(
-                            targetClass.substring(targetClass.lastIndexOf(".") 
+ 1),
+                    if (classExistsInDependency(
+                            targetClass.replace('.', '/') + ".class",
                             artifact.getFile())) {
                         
infrastructureServiceModel.setVersion(artifact.getVersion());
                         
infrastructureServiceModel.setGroupId(artifact.getGroupId());
@@ -127,16 +125,12 @@ public class CamelTestInfraGenerateMetadataMojo extends 
AbstractGeneratorMojo {
         }
     }
 
-    private boolean classExistsInJarFile(String className, File dependency) 
throws IOException {
+    private boolean classExistsInDependency(String classPath, File dependency) 
throws IOException {
+        if (dependency.isDirectory()) {
+            return new File(dependency, classPath).exists();
+        }
         try (JarFile jarFile = new JarFile(dependency)) {
-            Enumeration<JarEntry> e = jarFile.entries();
-            while (e.hasMoreElements()) {
-                JarEntry jarEntry = e.nextElement();
-                if (jarEntry.getName().contains(className)) {
-                    return true;
-                }
-            }
-            return false;
+            return jarFile.getEntry(classPath) != null;
         }
     }
 

Reply via email to