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 c70bcc3bac3 CAMEL-18151: camel-jbang - Export command for spring boot
c70bcc3bac3 is described below

commit c70bcc3bac30141b53d93056b3feb39116205859
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Tue May 31 11:12:19 2022 +0200

    CAMEL-18151: camel-jbang - Export command for spring boot
---
 dsl/camel-jbang/camel-jbang-core/pom.xml              | 10 ----------
 .../dsl/jbang/core/commands/ExportSpringBoot.java     | 19 +++++++++++++------
 2 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/dsl/camel-jbang/camel-jbang-core/pom.xml 
b/dsl/camel-jbang/camel-jbang-core/pom.xml
index c00d7021882..c3eb3147d06 100644
--- a/dsl/camel-jbang/camel-jbang-core/pom.xml
+++ b/dsl/camel-jbang/camel-jbang-core/pom.xml
@@ -63,16 +63,6 @@
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.apache.velocity</groupId>
-            <artifactId>velocity-engine-core</artifactId>
-            <version>${velocity-version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.freemarker</groupId>
-            <artifactId>freemarker</artifactId>
-            <version>${freemarker-version}</version>
-        </dependency>
         <dependency>
             <groupId>org.apache.logging.log4j</groupId>
             <artifactId>log4j-api</artifactId>
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java
index 48e82859d81..b2325c2d259 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java
@@ -37,6 +37,7 @@ import org.apache.camel.util.FileUtil;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.OrderedProperties;
 import org.apache.camel.util.StringHelper;
+import org.apache.commons.io.FileUtils;
 import picocli.CommandLine;
 
 @CommandLine.Command(name = "spring-boot", description = "Export as Spring 
Boot project")
@@ -124,14 +125,20 @@ class ExportSpringBoot extends CamelCommand {
         // create pom
         createPom(new File(BUILD_DIR, "pom.xml"), deps);
 
-        // move work dir to the export dir
-        if (!exportDir.equals(".")) {
-            // create the dir and copy over all files from work dir
+        if (exportDir.equals(".")) {
+            // we export to current dir so prepare for this by cleaning up 
existing files
             File target = new File(exportDir);
-            target.mkdirs();
-            Files.move(new File(BUILD_DIR).toPath(), target.toPath(), 
StandardCopyOption.ATOMIC_MOVE);
+            for (File f : target.listFiles()) {
+                if (!f.isHidden() && f.isDirectory()) {
+                    FileUtil.removeDir(f);
+                } else if (!f.isHidden() && f.isFile()) {
+                    f.delete();
+                }
+            }
         }
-        // TODO: If output is same folder (eg dot) then files should be moved 
instead of copy (or we delete all and move from work dir)
+        // copy to export dir and remove work dir
+        FileUtils.copyDirectory(new File(BUILD_DIR), new File("."));
+        FileUtil.removeDir(new File(BUILD_DIR));
 
         return 0;
     }

Reply via email to