You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/12/02 12:54:11 UTC

[camel] 02/02: CAMEL-18788: camel-jbang - Run with --dev should use reload dir of the file in case its from another folder than current.

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

commit c530c3fd701f051d3fae76cf2d4e54222939c734
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Dec 2 13:53:56 2022 +0100

    CAMEL-18788: camel-jbang - Run with --dev should use reload dir of the file in case its from another folder than current.
---
 .../java/org/apache/camel/dsl/jbang/core/commands/Run.java    | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

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 382353b7ab5..f67bdf16d8a 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
@@ -502,7 +502,16 @@ class Run extends CamelCommand {
         if (dev && sjReload.length() > 0) {
             String reload = sjReload.toString();
             main.addInitialProperty("camel.main.routesReloadEnabled", "true");
-            main.addInitialProperty("camel.main.routesReloadDirectory", ".");
+            // use current dir, however if we run a file that are in another folder, then we should track that folder instead
+            String reloadDir = ".";
+            for (String r : reload.split(",")) {
+                String path = FileUtil.onlyPath(r);
+                if (path != null) {
+                    reloadDir = path;
+                    break;
+                }
+            }
+            main.addInitialProperty("camel.main.routesReloadDirectory", reloadDir);
             main.addInitialProperty("camel.main.routesReloadPattern", reload);
             main.addInitialProperty("camel.main.routesReloadDirectoryRecursive", isReloadRecursive(reload) ? "true" : "false");
             // do not shutdown the JVM but stop routes when max duration is triggered