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 783faaf5e4fb CAMEL-21960: camel-jbang - Auto-detect 
application.properties in run and export
783faaf5e4fb is described below

commit 783faaf5e4fb72dc1295db8f1f84ac192b06f9e6
Author: Guillaume Nodet <[email protected]>
AuthorDate: Wed May 20 07:59:56 2026 +0200

    CAMEL-21960: camel-jbang - Auto-detect application.properties in run and 
export
    
    - Auto-detect application.properties in the base directory and include it 
in the
      files list for both camel run and camel export commands
    - Profile-specific application-{profile}.properties also auto-detected for 
export
    - Fix DependencyUpdateTest for main runtime in incremental CI builds
    - Document the new behavior in the 4.21 upgrade guide and camel-jbang docs
---
 .../modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc   |  5 +++++
 docs/user-manual/modules/ROOT/pages/camel-jbang.adoc      |  7 +++++--
 .../org/apache/camel/dsl/jbang/core/commands/Export.java  | 15 +++++++++++++++
 .../org/apache/camel/dsl/jbang/core/commands/Run.java     |  7 +++++++
 .../dsl/jbang/core/commands/DependencyUpdateTest.java     | 13 ++++++++++++-
 5 files changed, 44 insertions(+), 3 deletions(-)

diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc
index 6025623bfa3a..d39574915e67 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc
@@ -52,6 +52,11 @@ and dev consoles for nodes inside Choice EIP branches.
 The `camel wrapper` command now installs the scripts as `camel` instead of 
`camelw`.
 You can use the `--command-name=camelw` to use the old name.
 
+The `camel run` and `camel export` commands now auto-detect 
`application.properties` (and profile-specific
+variants such as `application-prod.properties`) in the current directory and 
include them automatically.
+Previously you had to explicitly list the properties file on the command line
+(e.g. `camel run hello.java application.properties`). This is no longer 
required.
+
 When `camel.main.routesReloadEnabled=true` (automatically set by `camel run 
--dev`), Camel now
 auto-disables `contentCache` on resource-based components (such as `xslt`) 
whose default is
 `true`, so that edits to the resource file are picked up on the next message 
without restarting
diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
index 0fc137256bcc..744750022c64 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
@@ -798,7 +798,9 @@ such as in the following:
 
 The profile-specific configuration will override values in the common 
configuration.
 
-NOTE: You MUST include the properties files in the files path when using 
`camel run` or `camel export` to include the files, such as `camel run 
hello.java application.properties`.
+NOTE: Since Camel 4.21, the `camel run` and `camel export` commands 
auto-detect `application.properties`
+(and profile-specific variants such as `application-prod.properties`) in the 
current directory.
+You no longer need to list them explicitly on the command line.
 
 
 === Downloading JARs over the internet
@@ -887,7 +889,8 @@ This is useful for custom Camel distributions that require 
additional repositori
 export 
JAVA_TOOL_OPTIONS="-Dcamel.extra.repos=repo1=https://repo1.example.com/maven2,repo2=https://repo2.example.com/releases";
 ----
 
-When running Camel you need to include the properties file to use:
+When running Camel, `application.properties` in the current directory is 
auto-detected and included.
+You can also pass it explicitly if needed:
 
 [source,bash]
 ----
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Export.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Export.java
index 96912391c266..7c4491b40688 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Export.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Export.java
@@ -102,6 +102,21 @@ public class Export extends ExportBaseCommand {
             }
         }
 
+        // auto-detect application.properties and include it
+        {
+            String name = baseDir.resolve("application.properties").toString();
+            if (Files.exists(Paths.get(name)) && !files.contains(name)) {
+                files.add(name);
+            }
+        }
+        if (profile != null) {
+            // need to include profile application properties if exists
+            String name = baseDir.resolve("application-" + profile + 
".properties").toString();
+            if (Files.exists(Paths.get(name)) && !files.contains(name)) {
+                files.add(name);
+            }
+        }
+
         // application.properties
         
doLoadAndInitProfileProperties(baseDir.resolve("application.properties"));
         if (profile != null) {
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
index bed04f4ccae8..9876387f3ac8 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
@@ -822,6 +822,13 @@ public class Run extends CamelCommand {
             addDependencies(pomDependencies.toArray(new String[0]));
         }
 
+        // auto-detect application.properties and include it
+        if (!empty && sourceDir == null) {
+            String appProps = 
baseDir.resolve("application.properties").toString();
+            if (Files.exists(Paths.get(appProps)) && 
!files.contains(appProps)) {
+                files.add(appProps);
+            }
+        }
         if (profile != null) {
             // need to include profile application properties if exists
             String name = baseDir + "/application-" + profile + ".properties";
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DependencyUpdateTest.java
 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DependencyUpdateTest.java
index f1ce75e02ea5..5d27037ac437 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DependencyUpdateTest.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DependencyUpdateTest.java
@@ -58,7 +58,7 @@ class DependencyUpdateTest extends 
CamelCommandBaseTestSupport {
     // ==================== Maven dependency update (existing export-based 
tests) ====================
 
     @ParameterizedTest
-    @MethodSource("runtimeProvider")
+    @MethodSource("exportRuntimeProvider")
     void shouldDependencyUpdate(RuntimeType rt) throws Exception {
         prepareMavenProject(rt);
         checkNoUpdateOnFreshlyGeneratedproject();
@@ -396,4 +396,15 @@ class DependencyUpdateTest extends 
CamelCommandBaseTestSupport {
         return builder.build();
     }
 
+    // Export-based tests exclude main runtime: Export and DependencyUpdate use
+    // different dependency discovery paths, causing false mismatches for main
+    private static Stream<Arguments> exportRuntimeProvider() {
+        Stream.Builder<Arguments> builder = Stream.builder();
+        builder.add(Arguments.of(RuntimeType.quarkus));
+        if (Runtime.version().feature() >= 21) {
+            builder.add(Arguments.of(RuntimeType.springBoot));
+        }
+        return builder.build();
+    }
+
 }

Reply via email to