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

davsclaus pushed a commit to branch CAMEL-24727-jbang-export-golden
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 1161f6125eaba2a9aa50cf5192342c83fce52c8f
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Oct 29 15:26:03 2026 +0100

    CAMEL-24727: camel-jbang - camel run starts its Maven processes through 
startProcess
    
    A test can then check what a run with Maven (--runtime=main, quarkus or
    spring-boot, or a Maven project) does without running Maven.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../apache/camel/dsl/jbang/core/commands/Run.java  | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 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 d6fc24f850c4..851af2eb226d 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
@@ -1832,7 +1832,7 @@ public class Run extends CamelCommand {
         pb.command(mvnCmd);
 
         pb.inheritIO(); // run in foreground (with IO so logs are visible)
-        Process p = pb.start();
+        Process p = startProcess(pb);
         processRef.set(p);
         this.spawnPid = p.pid();
         // wait for that process to exit as we run in foreground
@@ -1970,7 +1970,7 @@ public class Run extends CamelCommand {
         ProcessBuilder pb = new ProcessBuilder();
         pb.command(mvnCmd);
         pb.inheritIO();
-        Process p = pb.start();
+        Process p = startProcess(pb);
         processRef.set(p);
         exit = p.waitFor();
         if (exit != 0) {
@@ -2009,7 +2009,7 @@ public class Run extends CamelCommand {
         // run in the current directory (not the export folder), so the routes 
read and write files relative to
         // where camel run is started, as with JBang: file:orders in an 
example reads its orders folder (CAMEL-25423)
         pb.inheritIO(); // run in foreground (with IO so logs are visible)
-        p = pb.start();
+        p = startProcess(pb);
         processRef.set(p);
         appRef.set(p);
         this.spawnPid = p.pid();
@@ -2017,6 +2017,14 @@ public class Run extends CamelCommand {
         return p.waitFor();
     }
 
+    /**
+     * Starts a process of a run with Maven: the build of the project, or the 
application. Tests that check what such a
+     * run does replace it, so they run neither Maven nor the application.
+     */
+    protected Process startProcess(ProcessBuilder pb) throws IOException {
+        return pb.start();
+    }
+
     /**
      * The application name as configured in the exported project ({@code 
camel.main.name}), which is what the running
      * application reports to the CLI and the TUI.
@@ -2398,7 +2406,7 @@ public class Run extends CamelCommand {
         if (mavenOpts != null && !mavenOpts.isBlank()) {
             pb.environment().merge("MAVEN_OPTS", mavenOpts.trim(), (existing, 
extra) -> existing + " " + extra);
         }
-        Process p = pb.start();
+        Process p = startProcess(pb);
         processRef.set(p);
         this.spawnPid = p.pid();
         return p.waitFor();
@@ -2487,7 +2495,7 @@ public class Run extends CamelCommand {
         pb.command(cmd);
         pb.directory(projectDir.toFile());
         pb.inheritIO();
-        Process p = pb.start();
+        Process p = startProcess(pb);
         processRef.set(p);
         this.spawnPid = p.pid();
         return p.waitFor();
@@ -2632,7 +2640,7 @@ public class Run extends CamelCommand {
         pb.command(mvnCmd);
 
         pb.inheritIO(); // run in foreground (with IO so logs are visible)
-        Process p = pb.start();
+        Process p = startProcess(pb);
         processRef.set(p);
         this.spawnPid = p.pid();
         // wait for that process to exit as we run in foreground
@@ -2755,7 +2763,7 @@ public class Run extends CamelCommand {
         pb.command(cmd);
         pb.directory(projectDir.toFile());
         pb.inheritIO();
-        Process p = pb.start();
+        Process p = startProcess(pb);
         processRef.set(p);
         this.spawnPid = p.pid();
         return p.waitFor();

Reply via email to