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 2023/05/05 08:31:40 UTC

[camel] 02/02: Fix CS

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 5b836fe80eab73ccad4f23877ab52e2161e7576e
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri May 5 10:31:23 2023 +0200

    Fix CS
---
 .../apache/camel/dsl/jbang/core/commands/Run.java  | 56 ++++++++++++----------
 1 file changed, 30 insertions(+), 26 deletions(-)

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 5385fca1ec2..f7a42879d57 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
@@ -537,32 +537,7 @@ public class Run extends CamelCommand {
         }
 
         // we can only reload if file based
-        if (dev && (sourceDir != null || sjReload.length() > 0)) {
-            main.addInitialProperty("camel.main.routesReloadEnabled", "true");
-            if (sourceDir != null) {
-                main.addInitialProperty("camel.jbang.sourceDir", sourceDir);
-                main.addInitialProperty("camel.main.routesReloadDirectory", sourceDir);
-                main.addInitialProperty("camel.main.routesReloadPattern", "*");
-                main.addInitialProperty("camel.main.routesReloadDirectoryRecursive", "true");
-            } else {
-                String pattern = sjReload.toString();
-                String reloadDir = ".";
-                // use current dir, however if we run a file that are in another folder, then we should track that folder instead
-                for (String r : sjReload.toString().split(",")) {
-                    String path = FileUtil.onlyPath(r);
-                    if (path != null) {
-                        reloadDir = path;
-                        break;
-                    }
-                }
-                main.addInitialProperty("camel.main.routesReloadDirectory", reloadDir);
-                main.addInitialProperty("camel.main.routesReloadPattern", pattern);
-                main.addInitialProperty("camel.main.routesReloadDirectoryRecursive",
-                        isReloadRecursive(pattern) ? "true" : "false");
-            }
-            // do not shutdown the JVM but stop routes when max duration is triggered
-            main.addInitialProperty("camel.main.durationMaxAction", "stop");
-        }
+        setupReload(main, sjReload);
 
         if (propertiesFiles != null) {
             String[] filesLocation = propertiesFiles.split(",");
@@ -611,6 +586,35 @@ public class Run extends CamelCommand {
         }
     }
 
+    private void setupReload(KameletMain main, StringJoiner sjReload) {
+        if (dev && (sourceDir != null || sjReload.length() > 0)) {
+            main.addInitialProperty("camel.main.routesReloadEnabled", "true");
+            if (sourceDir != null) {
+                main.addInitialProperty("camel.jbang.sourceDir", sourceDir);
+                main.addInitialProperty("camel.main.routesReloadDirectory", sourceDir);
+                main.addInitialProperty("camel.main.routesReloadPattern", "*");
+                main.addInitialProperty("camel.main.routesReloadDirectoryRecursive", "true");
+            } else {
+                String pattern = sjReload.toString();
+                String reloadDir = ".";
+                // use current dir, however if we run a file that are in another folder, then we should track that folder instead
+                for (String r : sjReload.toString().split(",")) {
+                    String path = FileUtil.onlyPath(r);
+                    if (path != null) {
+                        reloadDir = path;
+                        break;
+                    }
+                }
+                main.addInitialProperty("camel.main.routesReloadDirectory", reloadDir);
+                main.addInitialProperty("camel.main.routesReloadPattern", pattern);
+                main.addInitialProperty("camel.main.routesReloadDirectoryRecursive",
+                        isReloadRecursive(pattern) ? "true" : "false");
+            }
+            // do not shutdown the JVM but stop routes when max duration is triggered
+            main.addInitialProperty("camel.main.durationMaxAction", "stop");
+        }
+    }
+
     private Properties loadProfileProperties() throws Exception {
         Properties answer = null;