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 db0e4452d82b CAMEL-23825: Fix spurious WARN log in 
readJandexIndexIgnoreMissing for missing jandex.idx
db0e4452d82b is described below

commit db0e4452d82bef9f1c10498032cab4b52763ccc1
Author: Guillaume Nodet <[email protected]>
AuthorDate: Fri Sep 11 10:21:53 2026 +0200

    CAMEL-23825: Fix spurious WARN log in readJandexIndexIgnoreMissing for 
missing jandex.idx
    
    * CAMEL-23825: Fix spurious WARN log in readJandexIndexIgnoreMissing for 
missing jandex.idx
    
    When the jandex.idx file simply does not exist (NoSuchFileException),
    PackagePluginUtils.readJandexIndexIgnoreMissing() was correctly detecting
    the case via doesNotExist() to skip the MojoExecutionException throw, but
    then falling through and still emitting a log.warn() with a full stack 
trace.
    
    A missing jandex.idx during build is an expected and normal condition for
    several modules (e.g. camel-xml-jaxb-dsl-test, camel-jbang-it) — it is
    not a failure. The WARN with stack trace was misleading and cluttered build
    logs unnecessarily.
    
    Fix: collapse the two-level if into a single guard that only throws (and
    previously warned) when the exception is present AND it is NOT a simple
    missing-file case. The log.warn() call is removed entirely since
    NoSuchFileException is silently ignored by design.
    
    Co-authored-by: Claude Sonnet 4.6 <[email protected]>
    
    * CAMEL-23825: Remove now-unused Log parameter from 
readJandexIndexIgnoreMissing
    
    Since the log.warn() call was removed in the previous commit, the Log
    parameter is no longer used. Drop it from the method signature and update
    all 5 callers in the same module.
    
    Co-authored-by: Claude Sonnet 4.6 <[email protected]>
    
    * CAMEL-23825: Remove readJandexIndexQuietly and joinHeaderAndSource from 
PackagePluginUtils
    
    - Delete readJandexIndexQuietly(): propagate MojoExecutionException properly
      through the call chains in SchemaGeneratorMojo and 
EndpointSchemaGeneratorMojo
      instead of swallowing it in a RuntimeException. All private methods that
      transitively call getIndex() now declare throws MojoExecutionException.
    - Delete joinHeaderAndSource(): trivial string concatenation inlined at its
      single call site in PrepareKameletMainMojo.
    - Switch CamelTestInfraGenerateMetadataMojo to readJandexIndex() directly.
    
    Co-authored-by: Claude Sonnet 4.6 <[email protected]>
    
    * CAMEL-23825: Add tests for readJandexIndexIgnoreMissing and use @TempDir
    
    - Add PackagePluginUtilsTest with two tests that directly exercise the
      fixed method: ignoresMissingJandexFile and throwsOnUnreadableJandexFile
    - Switch JandexStoreTest to use @TempDir instead of manual temp paths
    
    Co-authored-by: Hermes <[email protected]>
    
    ---------
    
    Co-authored-by: Claude Sonnet 4.6 <[email protected]>
    Co-authored-by: Hermes <[email protected]>
---
 .../packaging/AbstractGenerateConfigurerMojo.java  |  2 +-
 .../CamelTestInfraGenerateMetadataMojo.java        |  2 +-
 .../packaging/EndpointSchemaGeneratorMojo.java     | 17 ++++---
 .../packaging/GenerateDataTypeTransformerMojo.java |  2 +-
 .../maven/packaging/GenerateDevConsoleMojo.java    |  2 +-
 .../packaging/GenerateInvokeOnHeaderMojo.java      |  2 +-
 .../maven/packaging/GeneratePojoBeanMojo.java      |  2 +-
 .../maven/packaging/PrepareKameletMainMojo.java    |  3 +-
 .../camel/maven/packaging/SchemaGeneratorMojo.java | 25 +++++----
 .../packaging/generics/PackagePluginUtils.java     | 31 ++----------
 .../maven/packaging/generics/JandexStoreTest.java  | 59 ++++++++++++++++++++++
 .../packaging/generics/PackagePluginUtilsTest.java | 49 ++++++++++++++++++
 12 files changed, 143 insertions(+), 53 deletions(-)

diff --git 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/AbstractGenerateConfigurerMojo.java
 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/AbstractGenerateConfigurerMojo.java
index d72a6d662d57..19d7c600d2ea 100644
--- 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/AbstractGenerateConfigurerMojo.java
+++ 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/AbstractGenerateConfigurerMojo.java
@@ -136,7 +136,7 @@ public abstract class AbstractGenerateConfigurerMojo 
extends AbstractGeneratorMo
         Set<String> bootstrapSet = new LinkedHashSet<>();
         Set<String> bootstrapAndExtendedSet = new LinkedHashSet<>();
 
-        Index index = PackagePluginUtils.readJandexIndexIgnoreMissing(project, 
getLog());
+        Index index = PackagePluginUtils.readJandexIndexIgnoreMissing(project);
         if (discoverClasses) {
             if (index != null) {
                 // discover all classes annotated with @Configurer
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 27181414c377..0d37cae14889 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
@@ -78,7 +78,7 @@ public class CamelTestInfraGenerateMetadataMojo extends 
AbstractGeneratorMojo {
         // Collect infra-service.properties from all dependency JARs once (for 
embedded service GA hints)
         Properties infraServiceProps = collectInfraServiceProperties();
 
-        for (AnnotationInstance ai : 
PackagePluginUtils.readJandexIndexQuietly(project).getAnnotations(INFRA_SERVICE))
 {
+        for (AnnotationInstance ai : 
PackagePluginUtils.readJandexIndex(project).getAnnotations(INFRA_SERVICE)) {
 
             InfrastructureServiceModel infrastructureServiceModel = new 
InfrastructureServiceModel();
             String targetClass = ai.target().toString();
diff --git 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointSchemaGeneratorMojo.java
 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointSchemaGeneratorMojo.java
index 7fde90d74c5f..4326c293f800 100644
--- 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointSchemaGeneratorMojo.java
+++ 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointSchemaGeneratorMojo.java
@@ -151,7 +151,7 @@ public class EndpointSchemaGeneratorMojo extends 
AbstractGeneratorMojo {
         executeUriEndpoint();
     }
 
-    private void executeUriEndpoint() {
+    private void executeUriEndpoint() throws MojoExecutionException {
         List<Class<?>> classes = new ArrayList<>();
         for (AnnotationInstance ai : getIndex().getAnnotations(URI_ENDPOINT)) {
             Class<?> classElement = 
loadClass(ai.target().asClass().name().toString());
@@ -195,7 +195,8 @@ public class EndpointSchemaGeneratorMojo extends 
AbstractGeneratorMojo {
     private void processSchemas(
             Map<Class<?>, ComponentModel> models, Class<?> classElement, 
UriEndpoint uriEndpoint, String label,
             String[] schemes,
-            String[] titles, String[] extendsSchemes) {
+            String[] titles, String[] extendsSchemes)
+            throws MojoExecutionException {
         for (int i = 0; i < schemes.length; i++) {
             final String alias = schemes[i];
             final String extendsAlias = i < extendsSchemes.length ? 
extendsSchemes[i] : extendsSchemes[0];
@@ -262,7 +263,8 @@ public class EndpointSchemaGeneratorMojo extends 
AbstractGeneratorMojo {
     protected ComponentModel writeJSonSchemeAndPropertyConfigurer(
             Class<?> classElement, UriEndpoint uriEndpoint, String title,
             String scheme, String extendsScheme, String label,
-            String[] schemes, ComponentModel parentData) {
+            String[] schemes, ComponentModel parentData)
+            throws MojoExecutionException {
         // gather component information
         ComponentModel componentModel
                 = findComponentProperties(uriEndpoint, classElement, title, 
scheme, extendsScheme, label, schemes);
@@ -581,7 +583,7 @@ public class EndpointSchemaGeneratorMojo extends 
AbstractGeneratorMojo {
      * Used for enhancing the component model with apiProperties for API based 
components (such as twilio, olingo and
      * others)
      */
-    private void enhanceComponentModelWithApiModel(ComponentModel 
componentModel) {
+    private void enhanceComponentModelWithApiModel(ComponentModel 
componentModel) throws MojoExecutionException {
         for (AnnotationInstance ai : getIndex().getAnnotations(API_PARAMS)) {
             Class<?> classElement = 
loadClass(ai.target().asClass().name().toString());
             final ApiParams apiParams = 
classElement.getAnnotation(ApiParams.class);
@@ -820,7 +822,8 @@ public class EndpointSchemaGeneratorMojo extends 
AbstractGeneratorMojo {
 
     protected ComponentModel findComponentProperties(
             UriEndpoint uriEndpoint, Class<?> endpointClassElement, String 
title, String scheme,
-            String extendsScheme, String label, String[] schemes) {
+            String extendsScheme, String label, String[] schemes)
+            throws MojoExecutionException {
         ComponentModel model = new ComponentModel();
         model.setScheme(scheme);
         model.setName(scheme);
@@ -1784,9 +1787,9 @@ public class EndpointSchemaGeneratorMojo extends 
AbstractGeneratorMojo {
         updateResource(resourcesOutputDir.toPath(), 
"META-INF/services/org/apache/camel/configurer/" + name, w.toString());
     }
 
-    private IndexView getIndex() {
+    private IndexView getIndex() throws MojoExecutionException {
         if (indexView == null) {
-            indexView = PackagePluginUtils.readJandexIndexQuietly(project);
+            indexView = PackagePluginUtils.readJandexIndex(project);
         }
 
         return indexView;
diff --git 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GenerateDataTypeTransformerMojo.java
 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GenerateDataTypeTransformerMojo.java
index 5791ac1b2866..c78d54801fff 100644
--- 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GenerateDataTypeTransformerMojo.java
+++ 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GenerateDataTypeTransformerMojo.java
@@ -136,7 +136,7 @@ public class GenerateDataTypeTransformerMojo extends 
AbstractGeneratorMojo {
             resourcesOutputDir = new File(project.getBasedir(), 
"src/generated/resources");
         }
 
-        Index index = PackagePluginUtils.readJandexIndexIgnoreMissing(project, 
getLog());
+        Index index = PackagePluginUtils.readJandexIndexIgnoreMissing(project);
         if (index == null) {
             return;
         }
diff --git 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GenerateDevConsoleMojo.java
 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GenerateDevConsoleMojo.java
index c81ae8a06372..05b2f018ab22 100644
--- 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GenerateDevConsoleMojo.java
+++ 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GenerateDevConsoleMojo.java
@@ -174,7 +174,7 @@ public class GenerateDevConsoleMojo extends 
AbstractGeneratorMojo {
             resourcesOutputDir = new File(project.getBasedir(), 
"src/generated/resources");
         }
 
-        Index index = PackagePluginUtils.readJandexIndexIgnoreMissing(project, 
getLog());
+        Index index = PackagePluginUtils.readJandexIndexIgnoreMissing(project);
         if (index == null) {
             return;
         }
diff --git 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GenerateInvokeOnHeaderMojo.java
 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GenerateInvokeOnHeaderMojo.java
index 1e2c96e61a90..c9389a5d9e31 100644
--- 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GenerateInvokeOnHeaderMojo.java
+++ 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GenerateInvokeOnHeaderMojo.java
@@ -123,7 +123,7 @@ public class GenerateInvokeOnHeaderMojo extends 
AbstractGeneratorMojo {
             resourcesOutputDir = new File(project.getBasedir(), 
"src/generated/resources");
         }
 
-        Index index = PackagePluginUtils.readJandexIndexIgnoreMissing(project, 
getLog());
+        Index index = PackagePluginUtils.readJandexIndexIgnoreMissing(project);
         if (index == null) {
             return;
         }
diff --git 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GeneratePojoBeanMojo.java
 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GeneratePojoBeanMojo.java
index fc10ec789894..393338ee2f3d 100644
--- 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GeneratePojoBeanMojo.java
+++ 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/GeneratePojoBeanMojo.java
@@ -155,7 +155,7 @@ public class GeneratePojoBeanMojo extends 
AbstractGeneratorMojo {
             resourcesOutputDir = new File(project.getBasedir(), 
"src/generated/resources");
         }
 
-        Index index = PackagePluginUtils.readJandexIndexIgnoreMissing(project, 
getLog());
+        Index index = PackagePluginUtils.readJandexIndexIgnoreMissing(project);
         if (index == null) {
             return;
         }
diff --git 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareKameletMainMojo.java
 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareKameletMainMojo.java
index d847b4686476..19af7daae8a2 100644
--- 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareKameletMainMojo.java
+++ 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareKameletMainMojo.java
@@ -46,7 +46,6 @@ import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.build.BuildContext;
 
-import static 
org.apache.camel.maven.packaging.generics.PackagePluginUtils.joinHeaderAndSource;
 import static org.apache.camel.tooling.util.PackageHelper.loadText;
 
 /**
@@ -179,7 +178,7 @@ public class PrepareKameletMainMojo extends AbstractMojo {
         Path target = outputDir.toPath().resolve(filePath).resolve(fileName);
 
         try {
-            final String code = joinHeaderAndSource(licenseHeader, source);
+            final String code = licenseHeader + "\n" + source;
 
             if (getLog().isDebugEnabled()) {
                 getLog().debug("Source code generated:\n" + code);
diff --git 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SchemaGeneratorMojo.java
 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SchemaGeneratorMojo.java
index 4feb8da0c090..acf516afcc58 100644
--- 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SchemaGeneratorMojo.java
+++ 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SchemaGeneratorMojo.java
@@ -216,7 +216,7 @@ public class SchemaGeneratorMojo extends 
AbstractGeneratorMojo {
         }
     }
 
-    private void processModelClass(ClassInfo element) {
+    private void processModelClass(ClassInfo element) throws 
MojoExecutionException {
         // skip abstract classes
         if (Modifier.isAbstract(element.flags())) {
             return;
@@ -312,9 +312,9 @@ public class SchemaGeneratorMojo extends 
AbstractGeneratorMojo {
                 json);
     }
 
-    private IndexView getIndex() {
+    private IndexView getIndex() throws MojoExecutionException {
         if (indexView == null) {
-            indexView = PackagePluginUtils.readJandexIndexQuietly(project);
+            indexView = PackagePluginUtils.readJandexIndex(project);
         }
         return indexView;
     }
@@ -427,7 +427,8 @@ public class SchemaGeneratorMojo extends 
AbstractGeneratorMojo {
     protected void findClassProperties(
             Set<EipOptionModel> eipOptions,
             Class<?> originalClassType, Class<?> classElement,
-            String prefix, String modelName) {
+            String prefix, String modelName)
+            throws MojoExecutionException {
         while (true) {
             for (Field fieldElement : classElement.getDeclaredFields()) {
 
@@ -662,7 +663,8 @@ public class SchemaGeneratorMojo extends 
AbstractGeneratorMojo {
 
     private void processElement(
             Class<?> originalClassType, Class<?> classElement, XmlElement 
element, Field fieldElement,
-            Set<EipOptionModel> eipOptions, String prefix) {
+            Set<EipOptionModel> eipOptions, String prefix)
+            throws MojoExecutionException {
         String fieldName = fieldElement.getName();
         if (element != null) {
             Metadata metadata = fieldElement.getAnnotation(Metadata.class);
@@ -812,7 +814,7 @@ public class SchemaGeneratorMojo extends 
AbstractGeneratorMojo {
         eipOptions.add(ep);
     }
 
-    private void processRoute(Class<?> classElement, Set<EipOptionModel> 
eipOptions) {
+    private void processRoute(Class<?> classElement, Set<EipOptionModel> 
eipOptions) throws MojoExecutionException {
 
         // group
         String docComment = findJavaDoc(null, "group", null, classElement, 
true);
@@ -1094,7 +1096,8 @@ public class SchemaGeneratorMojo extends 
AbstractGeneratorMojo {
      */
     private void processOutputs(
             Class<?> originalClassType, XmlElementRef elementRef,
-            Field fieldElement, Method methodElement, String 
fieldOrMethodName, Set<EipOptionModel> eipOptions, String prefix) {
+            Field fieldElement, Method methodElement, String 
fieldOrMethodName, Set<EipOptionModel> eipOptions, String prefix)
+            throws MojoExecutionException {
 
         if ("outputs".equals(fieldOrMethodName) && 
supportOutputs(originalClassType)) {
             String name = fetchName(elementRef.name(), fieldOrMethodName, 
prefix);
@@ -1147,7 +1150,8 @@ public class SchemaGeneratorMojo extends 
AbstractGeneratorMojo {
      */
     private void processVerbs(
             Class<?> originalClassType, XmlElementRef elementRef, Field 
fieldElement,
-            String fieldName, Set<EipOptionModel> eipOptions, String prefix) {
+            String fieldName, Set<EipOptionModel> eipOptions, String prefix)
+            throws MojoExecutionException {
 
         if ("verbs".equals(fieldName) && supportOutputs(originalClassType)) {
             String name = fetchName(elementRef.name(), fieldName, prefix);
@@ -1226,7 +1230,8 @@ public class SchemaGeneratorMojo extends 
AbstractGeneratorMojo {
     private void processRefExpression(
             Class<?> originalClassType, Class<?> classElement,
             XmlElementRef elementRef, Field fieldElement,
-            String fieldName, Set<EipOptionModel> eipOptions, String prefix) {
+            String fieldName, Set<EipOptionModel> eipOptions, String prefix)
+            throws MojoExecutionException {
 
         if ("expression".equals(fieldName)) {
             String name = fetchName(elementRef.name(), fieldName, prefix);
@@ -1276,7 +1281,7 @@ public class SchemaGeneratorMojo extends 
AbstractGeneratorMojo {
         }
     }
 
-    private Set<String> getOneOfs(String[] classes) {
+    private Set<String> getOneOfs(String[] classes) throws 
MojoExecutionException {
         Set<String> oneOfTypes = new TreeSet<>();
         for (String superclass : classes) {
             for (ClassInfo ci : 
getIndex().getAllKnownSubclasses(DotName.createSimple(superclass))) {
diff --git 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/generics/PackagePluginUtils.java
 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/generics/PackagePluginUtils.java
index a0faae5cc6fb..1a16dd4b4110 100644
--- 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/generics/PackagePluginUtils.java
+++ 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/generics/PackagePluginUtils.java
@@ -20,7 +20,6 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 
 import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.project.MavenProject;
 import org.jboss.jandex.Index;
 
@@ -39,39 +38,15 @@ public final class PackagePluginUtils {
         return jandex.getIndex();
     }
 
-    public static Index readJandexIndexQuietly(MavenProject project) {
+    public static Index readJandexIndexIgnoreMissing(MavenProject project) 
throws MojoExecutionException {
         Path output = Paths.get(project.getBuild().getOutputDirectory());
         final JandexStore.Jandex jandex = JandexStore.read(output);
-        if (jandex.getException() != null) {
-            throw new RuntimeException("IOException: " + 
jandex.getException(), jandex.getException());
-        }
-
-        return jandex.getIndex();
-    }
-
-    public static Index readJandexIndexIgnoreMissing(MavenProject project, Log 
log) throws MojoExecutionException {
-        Path output = Paths.get(project.getBuild().getOutputDirectory());
-        final JandexStore.Jandex jandex = JandexStore.read(output);
-
-        if (jandex.getException() != null) {
-            if (!jandex.doesNotExist()) {
-                throw new MojoExecutionException(
-                        "IOException: " + jandex.getException().getMessage(), 
jandex.getException());
-            }
 
-            log.warn("Jandex reading failed: " + 
jandex.getException().getMessage(), jandex.getException());
+        if (jandex.getException() != null && !jandex.doesNotExist()) {
+            throw new MojoExecutionException("IOException: " + 
jandex.getException(), jandex.getException());
         }
 
         return jandex.getIndex();
     }
 
-    public static String joinHeaderAndSource(String licenseHeader, String 
source) {
-        StringBuilder sb = new StringBuilder(licenseHeader.length() + 
source.length() + 8);
-
-        sb.append(licenseHeader);
-        sb.append("\n");
-        sb.append(source);
-        return sb.toString();
-    }
-
 }
diff --git 
a/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/generics/JandexStoreTest.java
 
b/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/generics/JandexStoreTest.java
new file mode 100644
index 000000000000..4ecf92cb42cf
--- /dev/null
+++ 
b/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/generics/JandexStoreTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+package org.apache.camel.maven.packaging.generics;
+
+import java.nio.file.NoSuchFileException;
+import java.nio.file.Path;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class JandexStoreTest {
+
+    @Test
+    void doesNotExistReturnsTrueForNoSuchFileException() {
+        NoSuchFileException cause = new 
NoSuchFileException("/some/path/jandex.idx");
+        JandexStore.Jandex jandex = new JandexStore.Jandex(cause);
+
+        assertThat(jandex.doesNotExist()).isTrue();
+        assertThat(jandex.getException()).isSameAs(cause);
+        assertThat(jandex.getIndex()).isNull();
+    }
+
+    @Test
+    void doesNotExistReturnsFalseForOtherExceptions() {
+        Exception cause = new RuntimeException("some other I/O error");
+        JandexStore.Jandex jandex = new JandexStore.Jandex(cause);
+
+        assertThat(jandex.doesNotExist()).isFalse();
+        assertThat(jandex.getException()).isSameAs(cause);
+    }
+
+    @Test
+    void readReturnsDoesNotExistForMissingJandexFile(@TempDir Path tempDir) {
+        // A path that does not exist on disk
+        Path nonExistent = tempDir.resolve("missing-jandex.idx");
+        JandexStore.Jandex jandex = JandexStore.nonCachedRead(nonExistent);
+
+        assertThat(jandex.doesNotExist())
+                .as("Expected doesNotExist() to be true for a missing jandex 
file")
+                .isTrue();
+        assertThat(jandex.getIndex()).isNull();
+    }
+}
diff --git 
a/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/generics/PackagePluginUtilsTest.java
 
b/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/generics/PackagePluginUtilsTest.java
new file mode 100644
index 000000000000..fc07c9caa0d9
--- /dev/null
+++ 
b/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/generics/PackagePluginUtilsTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+package org.apache.camel.maven.packaging.generics;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+class PackagePluginUtilsTest {
+
+    @Test
+    void ignoresMissingJandexFile(@TempDir Path dir) throws Exception {
+        MavenProject project = new MavenProject();
+        project.getBuild().setOutputDirectory(dir.toString());
+        
assertThat(PackagePluginUtils.readJandexIndexIgnoreMissing(project)).isNull();
+    }
+
+    @Test
+    void throwsOnUnreadableJandexFile(@TempDir Path dir) throws Exception {
+        Path idx = dir.resolve(JandexStore.DEFAULT_NAME);
+        Files.createDirectories(idx.getParent());
+        Files.writeString(idx, "not a jandex index");
+        MavenProject project = new MavenProject();
+        project.getBuild().setOutputDirectory(dir.toString());
+        assertThatThrownBy(() -> 
PackagePluginUtils.readJandexIndexIgnoreMissing(project))
+                .isInstanceOf(MojoExecutionException.class);
+    }
+}

Reply via email to