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

tdiesler 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 7feb0e7a26f CAMEL-22028: camel-jbang - Regression with missing routes 
file
7feb0e7a26f is described below

commit 7feb0e7a26f8acde12cac9e7f39a5a3a7651122c
Author: Thomas Diesler <[email protected]>
AuthorDate: Tue Apr 29 16:24:56 2025 +0200

    CAMEL-22028: camel-jbang - Regression with missing routes file
---
 .../camel/dsl/jbang/core/commands/Export.java      | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Export.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Export.java
index 7b70debeff5..12fa8d3af77 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Export.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Export.java
@@ -17,8 +17,10 @@
 package org.apache.camel.dsl.jbang.core.commands;
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.InputStream;
+import java.nio.file.Paths;
 import java.text.SimpleDateFormat;
 import java.util.Comparator;
 import java.util.Date;
@@ -78,6 +80,13 @@ public class Export extends ExportBaseCommand {
             gav = "org.example.project:%s:%s".formatted(pn, getVersion());
         }
 
+        try {
+            verifyExportFiles();
+        } catch (FileNotFoundException ex) {
+            printer().println(ex.getMessage());
+            return 1;
+        }
+
         switch (runtime) {
             case springBoot -> {
                 return export(new ExportSpringBoot(getMain()));
@@ -95,6 +104,25 @@ public class Export extends ExportBaseCommand {
         }
     }
 
+    private void verifyExportFiles() throws FileNotFoundException {
+        for (var fn : files) {
+            if (fn.indexOf(':') < 0 || fn.startsWith("file:")) {
+                if (fn.startsWith("file:")) {
+                    fn = fn.substring(5);
+                    if (fn.startsWith("//")) {
+                        fn = fn.substring(2);
+                    }
+                }
+                if (fn.endsWith("/*")) {
+                    fn = fn.substring(0, fn.length() - 2);
+                }
+                if (!Paths.get(fn).toFile().exists()) {
+                    throw new FileNotFoundException("Path does not exist: " + 
fn);
+                }
+            }
+        }
+    }
+
     private void doLoadAndInitProfileProperties(File file) throws Exception {
         if (file.exists()) {
             Properties props = new CamelCaseOrderedProperties();

Reply via email to