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 522ac4fec7b1 CAMEL-26848: camel-jbang - camel export keeps a key of 
application.properties that the run settings repeat, such as 
camel.server.port=8080 (#29617)
522ac4fec7b1 is described below

commit 522ac4fec7b12d66c30acd65faf28585c9e9d893
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Nov 11 11:37:10 2026 +0100

    CAMEL-26848: camel-jbang - camel export keeps a key of 
application.properties that the run settings repeat, such as 
camel.server.port=8080 (#29617)
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 .../camel/dsl/jbang/run/export/Exporter.java       |  8 ++++-
 .../dsl/jbang/run/export/ProjectExporterTest.java  | 35 ++++++++++++++++++++++
 2 files changed, 42 insertions(+), 1 deletion(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/Exporter.java
 
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/Exporter.java
index c7b0f4cb9a52..319c079bff7d 100644
--- 
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/Exporter.java
+++ 
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/Exporter.java
@@ -830,6 +830,9 @@ abstract class Exporter {
         if (Files.exists(profile)) {
             RuntimeUtil.loadProperties(profileProps, profile);
         }
+        // the run settings repeat some keys of the application.properties, 
such as camel.server.port
+        Properties appProps = new CamelCaseOrderedProperties();
+        appProps.putAll(profileProps);
         profileProps.putAll(settingsProps);
         prepareApplicationProperties(profileProps);
 
@@ -838,7 +841,10 @@ abstract class Exporter {
             boolean skip = !key.startsWith("camel.main")
                     || "camel.main.routesCompileDirectory".equals(key)
                     || "camel.main.routesReloadEnabled".equals(key);
-            if (skip) {
+            if (skip && appProps.containsKey(key)) {
+                // a key of the application.properties is kept, as a route may 
refer to it: {{camel.server.port}}
+                profileProps.put(key, appProps.get(key));
+            } else if (skip) {
                 profileProps.remove(key);
             }
         }
diff --git 
a/dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/export/ProjectExporterTest.java
 
b/dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/export/ProjectExporterTest.java
index 0323af19f0fd..16ae4e91933f 100644
--- 
a/dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/export/ProjectExporterTest.java
+++ 
b/dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/export/ProjectExporterTest.java
@@ -86,6 +86,41 @@ class ProjectExporterTest {
         
assertThat(request.workDir.resolve(ExportHelper.RUN_SETTINGS_FILE)).exists();
     }
 
+    @Test
+    void keepsTheKeysOfTheApplicationPropertiesThatTheRunSettingsRepeat() 
throws Exception {
+        Path route = writeRoute("shop");
+        Files.writeString(dir.resolve("application.properties"), """
+                order.period=1000
+                camel.server.port=8080
+                """);
+        // the run settings repeat camel.server.port of the 
application.properties, as camel run does
+        DependencyResolver repeating = r -> {
+            Path settings = r.workDir.resolve(ExportHelper.RUN_SETTINGS_FILE);
+            Files.createDirectories(settings.getParent());
+            Files.writeString(settings, """
+                    camel.main.routesIncludePattern=file:%s
+                    
camel.component.properties.location=file:application.properties
+                    camel.server.port=8080
+                    dependency=camel:timer
+                    dependency=camel:log
+                    """.formatted(r.files.get(0)));
+            return 0;
+        };
+        Path exportDir = dir.resolve("export");
+        ExportRequest request = request(route, exportDir);
+        request.baseDir = dir;
+
+        StringPrinter printer = new StringPrinter();
+        int exit = new ProjectExporter(new 
ExportContext().withPrinter(printer).withDependencyResolver(repeating))
+                .export(request);
+
+        assertThat(exit).as(printer.getOutput()).isZero();
+        // a route may refer to it, {{camel.server.port}}, even when it is the 
default port
+        
assertThat(exportDir.resolve("src/main/resources/application.properties")).content()
+                .contains("order.period=1000", "camel.server.port=8080")
+                .doesNotContain("camel.component.properties.location");
+    }
+
     @Test
     void exportsInParallelWithWorkDirsOfTheirOwn() throws Exception {
         List<String> before = listWorkDir();

Reply via email to