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/04/18 06:40:05 UTC

[camel] branch main updated: CAMEL-17978: camel-jbang - Skip adding readme files to classpath

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 bc0b585e1dd CAMEL-17978: camel-jbang - Skip adding readme files to classpath
bc0b585e1dd is described below

commit bc0b585e1dd523b2b4f5db49406045e5891a6dd4
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Apr 18 08:39:52 2022 +0200

    CAMEL-17978: camel-jbang - Skip adding readme files to classpath
---
 .../apache/camel/dsl/jbang/core/commands/Run.java  | 24 ++++++++++++++++++++++
 1 file changed, 24 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 e73cb1256ed..922139e6ab7 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
@@ -25,6 +25,7 @@ import java.net.http.HttpResponse;
 import java.nio.file.FileSystems;
 import java.time.Duration;
 import java.util.Arrays;
+import java.util.Locale;
 import java.util.StringJoiner;
 import java.util.concurrent.Callable;
 import java.util.concurrent.Executors;
@@ -249,6 +250,9 @@ class Run implements Callable<Integer> {
 
         for (String file : files) {
 
+            if (skipFile(file)) {
+                continue;
+            }
             if (!knownFile(file)) {
                 // non known files to be added on classpath
                 sjClasspathFiles.add(file);
@@ -508,4 +512,24 @@ class Run implements Callable<Integer> {
         }
     }
 
+    private boolean skipFile(String name) {
+        if (name.startsWith(".")) {
+            return true;
+        }
+        if ("pom.xml".equalsIgnoreCase(name)) {
+            return true;
+        }
+        if ("build.gradle".equalsIgnoreCase(name)) {
+            return true;
+        }
+
+        String on = FileUtil.onlyName(name, true);
+        on = on.toLowerCase(Locale.ROOT);
+        if (on.startsWith("readme")) {
+            return true;
+        }
+
+        return false;
+    }
+
 }