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 198a212  CAMEL-17781: camel-jbang - Skip non accepted files when using 
camel run *
198a212 is described below

commit 198a212fb602915d0d1356fa3c89ca11e9656595
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Mar 11 09:24:14 2022 +0100

    CAMEL-17781: camel-jbang - Skip non accepted files when using camel run *
---
 .../org/apache/camel/dsl/jbang/core/commands/Run.java     | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

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 0130588..18819fe 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
@@ -24,6 +24,7 @@ import java.net.http.HttpRequest;
 import java.net.http.HttpResponse;
 import java.nio.file.FileSystems;
 import java.time.Duration;
+import java.util.Arrays;
 import java.util.StringJoiner;
 import java.util.concurrent.Callable;
 import java.util.concurrent.Executors;
@@ -45,6 +46,10 @@ import picocli.CommandLine.Parameters;
 
 @Command(name = "run", description = "Run Camel")
 class Run implements Callable<Integer> {
+
+    private static String[] ACCEPTED_FILE_EXT
+            = new String[] { "properties", "java", "groovy", "js", "jsh", 
"kts", "xml", "yaml" };
+
     private CamelContext context;
     private File lockFile;
     private ScheduledExecutorService executor;
@@ -225,6 +230,11 @@ class Run implements Callable<Integer> {
         StringJoiner js = new StringJoiner(",");
         StringJoiner sjReload = new StringJoiner(",");
         for (String file : files) {
+
+            if (!acceptFile(file)) {
+                continue;
+            }
+
             // check for properties files
             if (file.endsWith(".properties")) {
                 if (!ResourceHelper.hasScheme(file) && 
!file.startsWith("github:")) {
@@ -444,4 +454,9 @@ class Run implements Callable<Integer> {
         }
     }
 
+    private boolean acceptFile(String file) {
+        String ext = FileUtil.onlyExt(file, true);
+        return Arrays.stream(ACCEPTED_FILE_EXT).anyMatch(e -> 
e.equalsIgnoreCase(ext));
+    }
+
 }

Reply via email to