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 83cca9f209de CAMEL-26930: camel-jbang - dev mode does not reload for
logs, target, .git and the Camel folders in the source directory (#29928)
83cca9f209de is described below
commit 83cca9f209def8afbb85a79fadbc8dab26d58dfa
Author: Claus Ibsen <[email protected]>
AuthorDate: Sat Nov 14 19:27:00 2026 +0100
CAMEL-26930: camel-jbang - dev mode does not reload for logs, target, .git
and the Camel folders in the source directory (#29928)
camel dev > run.log in the project folder reloaded all the routes every 2
seconds: the
reload pattern of a source directory is every file but the test and data
folders, and
the log the run writes is a change on every scan, as are target, .git and
the
.camel-jbang and .camel folders. The pattern leaves them out now.
CAMEL-26930: camel-core - the reload test covers the .camel-jbang folder too
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../support/RouteWatcherReloadDataDirTest.java | 25 ++++++++++++++++++++++
.../modules/ROOT/pages/camel-jbang-running.adoc | 4 ++++
.../camel/dsl/jbang/core/commands/RunTest.java | 7 +++---
.../golden/expected/maven-main-mixed.maven.txt | 2 +-
.../apache/camel/dsl/jbang/run/RunPipeline.java | 8 +++++++
5 files changed, 42 insertions(+), 4 deletions(-)
diff --git
a/core/camel-core/src/test/java/org/apache/camel/support/RouteWatcherReloadDataDirTest.java
b/core/camel-core/src/test/java/org/apache/camel/support/RouteWatcherReloadDataDirTest.java
index 16eeb1f692b3..2507a0cdfd6a 100644
---
a/core/camel-core/src/test/java/org/apache/camel/support/RouteWatcherReloadDataDirTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/support/RouteWatcherReloadDataDirTest.java
@@ -119,6 +119,31 @@ public class RouteWatcherReloadDataDirTest extends
ContextTestSupport {
assertThat(scanNames()).containsExactly("readme.txt",
"shop.camel.yaml");
}
+ @Test
+ public void testTheFilesARunWritesAreNotWatched() throws Exception {
+ // CAMEL-26930: camel dev > run.log in the project reloaded all the
routes every 2 seconds; the pattern of
+ // camel run --dev with a source directory leaves out logs, the build
output, git and the Camel folders
+
start("*,!test/**,!*.log,!target/**,!.git/**,!.camel/**,!.camel-jbang/**");
+ assertThat(scanNames()).containsExactly("order-0.json",
"order-1.json", "shop.camel.yaml");
+
+ Files.writeString(dir.resolve("run.log"), "a line");
+ Files.createDirectories(dir.resolve("logs"));
+ Files.writeString(dir.resolve("logs/app.log"), "a line");
+ Files.createDirectories(dir.resolve("target/classes"));
+ Files.writeString(dir.resolve("target/classes/Foo.class"), "bytes");
+ Files.createDirectories(dir.resolve(".git"));
+ Files.writeString(dir.resolve(".git/index"), "index");
+ Files.createDirectories(dir.resolve(".camel"));
+ Files.writeString(dir.resolve(".camel/order-1.json"), "{}");
+ Files.createDirectories(dir.resolve(".camel-jbang"));
+ Files.writeString(dir.resolve(".camel-jbang/app.lock"), "lock");
+ assertThat(scanNames()).isEmpty();
+
+ // the route is still watched
+ Files.writeString(dir.resolve("shop.camel.yaml"), "one and two");
+ assertThat(scanNames()).containsExactly("shop.camel.yaml");
+ }
+
@Test
public void testTestFolderIsNotWatched() throws Exception {
// CAMEL-26494: the pattern of camel run --dev with a source directory
leaves the test folder out, with the
diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang-running.adoc
b/docs/user-manual/modules/ROOT/pages/camel-jbang-running.adoc
index 6e09557b30b3..e2dba168bb6b 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-jbang-running.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-jbang-running.adoc
@@ -112,6 +112,10 @@ The `test` folder of the source directory holds the Citrus
tests of the project
run with `camel test run`) and their data, which are not routes either: dev
mode does not watch it, so editing a test
does not reload the routes. Keep the routes out of `test`.
+Neither does dev mode watch the files that a run and the tools write in the
source directory: log files (`*.log`, such
+as the output of `camel dev > run.log`), the build output in `target`, `.git`,
and the `.camel-jbang` and `.camel`
+folders of the Camel CLI and the file consumer.
+
=== Live reload of resource files
In dev mode, Camel disables `contentCache` on resource-based components (such
as `xslt`)
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/RunTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/RunTest.java
index b354e9b0b992..bd379de5e144 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/RunTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/RunTest.java
@@ -368,10 +368,11 @@ class RunTest extends CamelCommandBaseTestSupport {
void sourceDirReloadPatternLeavesTheDataDirsOut() {
// CAMEL-25670: the routes read and write the files of a data folder,
which must not reload them
// CAMEL-26494: nor must the test folder, with the Citrus tests of the
project, which are not routes
-
assertThat(RunPipeline.sourceDirReloadPattern(null)).isEqualTo("*,!test/**");
-
assertThat(RunPipeline.sourceDirReloadPattern("inbox")).isEqualTo("*,!test/**,!inbox/**");
+ String ignored =
"!*.log,!target/**,!.git/**,!.camel/**,!.camel-jbang/**";
+
assertThat(RunPipeline.sourceDirReloadPattern(null)).isEqualTo("*,!test/**," +
ignored);
+
assertThat(RunPipeline.sourceDirReloadPattern("inbox")).isEqualTo("*,!test/**,"
+ ignored + ",!inbox/**");
assertThat(RunPipeline.sourceDirReloadPattern(" inbox , ./archive/
,data\\in,"))
- .isEqualTo("*,!test/**,!inbox/**,!archive/**,!data/in/**");
+ .isEqualTo("*,!test/**," + ignored +
",!inbox/**,!archive/**,!data/in/**");
}
@Test
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/resources/golden/expected/maven-main-mixed.maven.txt
b/dsl/camel-jbang/camel-jbang-core/src/test/resources/golden/expected/maven-main-mixed.maven.txt
index d3051a99b51f..c4f4ff3b7d13 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/resources/golden/expected/maven-main-mixed.maven.txt
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/resources/golden/expected/maven-main-mixed.maven.txt
@@ -13,7 +13,7 @@ ${java.home}/bin/java
-Dcamel.main.profile=dev
-Dcamel.main.routesReloadEnabled=true
-Dcamel.main.routesReloadDirectory=${basedir}/src/test/resources/golden/mixed
--Dcamel.main.routesReloadPattern=*,!test/**
+-Dcamel.main.routesReloadPattern=*,!test/**,!*.log,!target/**,!.git/**,!.camel/**,!.camel-jbang/**
-Dcamel.main.routesReloadDirectoryRecursive=true
-Dcamel.main.routesReloadRemoveAllRoutes=true
-jar
diff --git
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/RunPipeline.java
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/RunPipeline.java
index 44b083d99af9..f77c29953d1b 100644
---
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/RunPipeline.java
+++
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/RunPipeline.java
@@ -1206,11 +1206,19 @@ public class RunPipeline {
* the Citrus tests of the project (run with camel test run) and their
data, none of them routes (CAMEL-26494), and
* the data folders (--data-dir), whose files the routes read and write: a
change there is not a change of the
* sources, and reloading the routes for it restarts them, so they write
again and reload again (CAMEL-25670).
+ * Neither are the files that a run or the tools write in the project:
logs (camel dev > run.log reloaded all the
+ * routes every 2 seconds, CAMEL-26930), the build output, git, and the
folders of the Camel CLI and the file
+ * consumer (.camel-jbang, .camel).
*/
public static String sourceDirReloadPattern(String dataDir) {
StringJoiner sj = new StringJoiner(",");
sj.add("*");
sj.add("!test/**");
+ sj.add("!*.log");
+ sj.add("!target/**");
+ sj.add("!.git/**");
+ sj.add("!.camel/**");
+ sj.add("!.camel-jbang/**");
if (dataDir != null) {
for (String dir : dataDir.split(",")) {
dir = dir.trim().replace('\\', '/');