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

davsclaus 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 5c25a8ca673a CAMEL-28072: camel-catalog - update-camel-releases reads 
the old releases from the project base directory (#31294)
5c25a8ca673a is described below

commit 5c25a8ca673a5e201185568e4c4b5a922a6c4224
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Dec 2 21:55:45 2026 +0100

    CAMEL-28072: camel-catalog - update-camel-releases reads the old releases 
from the project base directory (#31294)
    
    The goal read src/main/resources/.../old-camel-releases.json relative to 
the working directory, so it failed when
    run with -pl from the root of the repository, as the release guide and the 
weekly sync-catalog-website.yml workflow
    do. The workflow has failed on main, 4.22.x and 4.18.x on every run since 
it was added.
    
    The old releases are now read from project.getBasedir(), and 
UpdateCamelReleasesMojoTest loads them from a @TempDir
    base directory that is not the working directory.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../maven/packaging/UpdateCamelReleasesMojo.java   | 10 +++--
 .../packaging/UpdateCamelReleasesMojoTest.java     | 49 ++++++++++++++++++++++
 2 files changed, 56 insertions(+), 3 deletions(-)

diff --git 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateCamelReleasesMojo.java
 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateCamelReleasesMojo.java
index f7778e5bcbdf..2a0635b33a62 100644
--- 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateCamelReleasesMojo.java
+++ 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateCamelReleasesMojo.java
@@ -89,7 +89,7 @@ public class UpdateCamelReleasesMojo extends 
AbstractGeneratorMojo {
         JsonArray arr = new JsonArray();
         if ("Camel".equals(kind)) {
             // include old releases
-            arr.addAll(processOldReleases());
+            arr.addAll(processOldReleases(project.getBasedir()));
         }
         for (ReleaseModel r : releases) {
             // kind: legacy should be kind: lts
@@ -107,8 +107,12 @@ public class UpdateCamelReleasesMojo extends 
AbstractGeneratorMojo {
         addResourceDirectory(path);
     }
 
-    private JsonArray processOldReleases() throws Exception {
-        File f = new 
File("src/main/resources/org/apache/camel/catalog/releases/old-camel-releases.json");
+    /**
+     * Loads the old releases relative to the base directory of the project, 
as the goal runs with -pl from the root of
+     * the repository, where the working directory is not the project.
+     */
+    static JsonArray processOldReleases(File baseDir) throws Exception {
+        File f = new File(baseDir, 
"src/main/resources/org/apache/camel/catalog/releases/old-camel-releases.json");
         String json = PackageHelper.loadText(f);
         return Jsoner.deserialize(json, new JsonArray());
     }
diff --git 
a/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/UpdateCamelReleasesMojoTest.java
 
b/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/UpdateCamelReleasesMojoTest.java
new file mode 100644
index 000000000000..e60afafd9830
--- /dev/null
+++ 
b/tooling/maven/camel-package-maven-plugin/src/test/java/org/apache/camel/maven/packaging/UpdateCamelReleasesMojoTest.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;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import org.apache.camel.util.json.JsonArray;
+import org.apache.camel.util.json.JsonObject;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * CAMEL-28072: the old releases are read relative to the base directory of 
the project, not the working directory, so
+ * the goal works when run with -pl from the root of the repository.
+ */
+class UpdateCamelReleasesMojoTest {
+
+    @Test
+    void oldReleasesAreReadFromTheProjectBaseDir(@TempDir Path baseDir) throws 
Exception {
+        Path dir = 
baseDir.resolve("src/main/resources/org/apache/camel/catalog/releases");
+        Files.createDirectories(dir);
+        Files.writeString(dir.resolve("old-camel-releases.json"), """
+                [{"version": "2.0.0", "date": "2009-08-24", "kind": 
"legacy"}]""");
+
+        // the working directory of the test (the plugin module) has no such 
file
+        
assertThat(Path.of("src/main/resources/org/apache/camel/catalog/releases/old-camel-releases.json")).doesNotExist();
+
+        JsonArray old = 
UpdateCamelReleasesMojo.processOldReleases(baseDir.toFile());
+        assertThat(old).hasSize(1);
+        assertThat(((JsonObject) 
old.get(0)).getString("version")).isEqualTo("2.0.0");
+    }
+}

Reply via email to