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 2021/12/01 10:51:50 UTC

[camel] branch main updated (adad1d7 -> a1ce215)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from adad1d7  CAMEL-17249: camel-jbang - Add troubleshooting to docs
     new 98aca04  Polished
     new f4ccc52  CAMEL-17256: camel-jbang - Allow to run multiple files
     new a1ce215  CAMEL-17256: camel-jbang - Allow to run multiple files

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../modules/ROOT/pages/camel-jbang.adoc            | 17 ++++++++
 .../apache/camel/dsl/jbang/core/commands/Run.java  | 49 +++++++++++++---------
 .../camel-jbang-main/dist/CamelJBang.java          |  5 +++
 .../src/main/jbang/main/CamelJBang.java            |  5 +++
 4 files changed, 57 insertions(+), 19 deletions(-)

[camel] 02/03: CAMEL-17256: camel-jbang - Allow to run multiple files

Posted by da...@apache.org.
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 f4ccc5226f6247975755e261f00481e333428ef5
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Dec 1 11:46:36 2021 +0100

    CAMEL-17256: camel-jbang - Allow to run multiple files
---
 .../apache/camel/dsl/jbang/core/commands/Run.java  | 49 +++++++++++++---------
 1 file changed, 30 insertions(+), 19 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 ad98c01..ef3b6f2 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
@@ -19,6 +19,7 @@ package org.apache.camel.dsl.jbang.core.commands;
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.FileSystems;
+import java.util.StringJoiner;
 import java.util.concurrent.Callable;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
@@ -38,8 +39,8 @@ class Run implements Callable<Integer> {
     private File lockFile;
     private ScheduledExecutorService executor;
 
-    @Parameters(description = "The Camel file to run", arity = "0..1")
-    private String file;
+    @Parameters(description = "The Camel file(s) to run", arity = "1")
+    private String[] files;
 
     //CHECKSTYLE:OFF
     @Option(names = { "-h", "--help" }, usageHelp = true, description = "Display the help and sub-commands")
@@ -150,29 +151,39 @@ class Run implements Callable<Integer> {
             }, 1000, 1000, TimeUnit.MILLISECONDS);
         }
 
-        if (!ResourceHelper.hasScheme(file) && !file.startsWith("github:")) {
-            file = "file:" + file;
-        }
-        main.addInitialProperty("camel.main.routesIncludePattern", file);
+        StringJoiner js = new StringJoiner(",");
+        StringJoiner sjReload = new StringJoiner(",");
+        for (String file : files) {
+            if (!ResourceHelper.hasScheme(file) && !file.startsWith("github:")) {
+                file = "file:" + file;
+            }
 
-        if (file.startsWith("file:")) {
             // check if file exist
-            File inputFile = new File(file.substring(5));
-            if (!inputFile.exists() && !inputFile.isFile()) {
-                System.err.println("File does not exist: " + file);
-                return 1;
+            if (file.startsWith("file:")) {
+                File inputFile = new File(file.substring(5));
+                if (!inputFile.exists() && !inputFile.isFile()) {
+                    System.err.println("File does not exist: " + files);
+                    return 1;
+                }
             }
 
-            // we can only reload if file based
-            if (reload) {
-                main.addInitialProperty("camel.main.routesReloadEnabled", "true");
-                main.addInitialProperty("camel.main.routesReloadDirectory", ".");
-                // skip file: as prefix
-                main.addInitialProperty("camel.main.routesReloadPattern", file.substring(5));
-                // do not shutdown the JVM but stop routes when max duration is triggered
-                main.addInitialProperty("camel.main.durationMaxAction", "stop");
+            js.add(file);
+            if (reload && file.startsWith("file:")) {
+                // we can only reload if file based
+                sjReload.add(file.substring(5));
             }
         }
+        main.addInitialProperty("camel.main.routesIncludePattern", js.toString());
+
+        // we can only reload if file based
+        if (reload && sjReload.length() > 0) {
+            main.addInitialProperty("camel.main.routesReloadEnabled", "true");
+            main.addInitialProperty("camel.main.routesReloadDirectory", ".");
+            // skip file: as prefix
+            main.addInitialProperty("camel.main.routesReloadPattern", sjReload.toString());
+            // do not shutdown the JVM but stop routes when max duration is triggered
+            main.addInitialProperty("camel.main.durationMaxAction", "stop");
+        }
 
         if (propertiesFiles != null) {
             String[] filesLocation = propertiesFiles.split(",");

[camel] 01/03: Polished

Posted by da...@apache.org.
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 98aca048b6b13406c82df5132ed30bed70d5b1c2
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Dec 1 11:37:47 2021 +0100

    Polished
---
 dsl/camel-jbang/camel-jbang-main/dist/CamelJBang.java                | 5 +++++
 dsl/camel-jbang/camel-jbang-main/src/main/jbang/main/CamelJBang.java | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/dsl/camel-jbang/camel-jbang-main/dist/CamelJBang.java b/dsl/camel-jbang/camel-jbang-main/dist/CamelJBang.java
index 9e36eca..cebf87c 100755
--- a/dsl/camel-jbang/camel-jbang-main/dist/CamelJBang.java
+++ b/dsl/camel-jbang/camel-jbang-main/dist/CamelJBang.java
@@ -26,8 +26,13 @@ package main;
 
 import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
 
+/**
+ * Main to run CamelJBang
+ */
 public class CamelJBang {
+
     public static void main(String... args) {
         CamelJBangMain.run(args);
     }
+
 }
diff --git a/dsl/camel-jbang/camel-jbang-main/src/main/jbang/main/CamelJBang.java b/dsl/camel-jbang/camel-jbang-main/src/main/jbang/main/CamelJBang.java
index 9e36eca..cebf87c 100755
--- a/dsl/camel-jbang/camel-jbang-main/src/main/jbang/main/CamelJBang.java
+++ b/dsl/camel-jbang/camel-jbang-main/src/main/jbang/main/CamelJBang.java
@@ -26,8 +26,13 @@ package main;
 
 import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
 
+/**
+ * Main to run CamelJBang
+ */
 public class CamelJBang {
+
     public static void main(String... args) {
         CamelJBangMain.run(args);
     }
+
 }

[camel] 03/03: CAMEL-17256: camel-jbang - Allow to run multiple files

Posted by da...@apache.org.
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 a1ce2153a69ebfecf49b896b75bf7ec31eb38d2a
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Dec 1 11:50:58 2021 +0100

    CAMEL-17256: camel-jbang - Allow to run multiple files
---
 docs/user-manual/modules/ROOT/pages/camel-jbang.adoc | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
index db02fb9..223c3680 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
@@ -77,6 +77,23 @@ jbang -Dcamel.jbang.version=3.14.0 CamelJBang@apache/camel run jms-amqp-10-sink-
 
 NOTE: it is necessary to have a AMQP 1.0 broker, such as Apache Artemis, running locally and listening on port 61616. Adjust the route accordingly if using a different address for the broker.
 
+=== Running Routes from multiple files
+
+You can run more than 1 file, for example to run two YAML files you can do:
+
+[source,bash]
+----
+jbang -Dcamel.jbang.version=3.14.0 CamelJBang@apache/camel run one.yaml two.yaml
+----
+
+You can also mix different xref:dsl.adoc[DSLs] such as yaml and Java:
+
+[source,bash]
+----
+jbang -Dcamel.jbang.version=3.14.0 CamelJBang@apache/camel run one.yaml hello.java
+----
+
+
 === Live reload
 
 You can enable live reload of the route(s) when the source file is updated (saved),