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 6025623bfa3a9..d39574915e677 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 0fc137256bcc8..744750022c64e 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 96912391c2660..7c4491b40688e 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 @@ protected Integer doExport() throws Exception { } } + // 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 bed04f4ccae8e..9876387f3ac89 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 @@ private int run() throws Exception { 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 f1ce75e02ea59..5d27037ac437a 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 @@ void end() { // ==================== 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 @@ private static Stream runtimeProvider() { 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 exportRuntimeProvider() { + Stream.Builder builder = Stream.builder(); + builder.add(Arguments.of(RuntimeType.quarkus)); + if (Runtime.version().feature() >= 21) { + builder.add(Arguments.of(RuntimeType.springBoot)); + } + return builder.build(); + } + }