From ac6db97a6735d754171a7518eb2001ab5824da81 Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Wed, 4 Oct 2023 16:45:30 +0200 Subject: [PATCH] CAMEL-19949: camel-jbang - Add --jvm-debug-port option --- .../camel/dsl/jbang/core/commands/Run.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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 ad0e0856925cb..18b159c790a13 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 @@ -169,6 +169,9 @@ public class Run extends CamelCommand { @Option(names = { "--jvm-debug" }, defaultValue = "false", description = "To enable JVM remote debug on localhost:4004") boolean jvmDebug; + @Option(names = { "--jvm-debug-port" }, description = "JVM remote debug port (default is 4004)") + int jvmDebugPort; + @Option(names = { "--name" }, defaultValue = "CamelJBang", description = "The name of the Camel application") String name; @@ -795,6 +798,7 @@ private Properties loadProfileProperties() throws Exception { download = "true".equals(answer.getProperty("camel.jbang.download", download ? "true" : "false")); background = "true".equals(answer.getProperty("camel.jbang.background", background ? "true" : "false")); jvmDebug = "true".equals(answer.getProperty("camel.jbang.jvmDebug", jvmDebug ? "true" : "false")); + jvmDebugPort = Integer.parseInt(answer.getProperty("camel.jbang.jvmDebugPort", String.valueOf(jvmDebugPort))); camelVersion = answer.getProperty("camel.jbang.camel-version", camelVersion); kameletsVersion = answer.getProperty("camel.jbang.kameletsVersion", kameletsVersion); gav = answer.getProperty("camel.jbang.gav", gav); @@ -832,8 +836,13 @@ protected int runCamelVersion(KameletMain main) throws Exception { jbangArgs.add("-Dcamel-kamelets.version=" + kameletsVersion); } if (jvmDebug) { - jbangArgs.add("--debug"); // jbang --debug + if (jvmDebugPort > 0) { + jbangArgs.add("--debug=" + jvmDebugPort); // jbang --debug=port + } else { + jbangArgs.add("--debug"); // jbang --debug + } cmds.remove("--jvm-debug"); + cmds.removeIf(s -> s.startsWith("--jvm-debug-port")); } if (repos != null) { @@ -842,6 +851,9 @@ protected int runCamelVersion(KameletMain main) throws Exception { jbangArgs.add("camel@apache/camel"); jbangArgs.addAll(cmds); + if (verbose) { + System.out.println(jbangArgs); + } ProcessBuilder pb = new ProcessBuilder(); pb.command(jbangArgs); if (background) { @@ -865,6 +877,9 @@ protected int runBackground(KameletMain main) throws Exception { cmds.add(0, "camel"); + if (verbose) { + System.out.println(cmds); + } ProcessBuilder pb = new ProcessBuilder(); pb.command(cmds); Process p = pb.start(); @@ -934,6 +949,9 @@ protected int runCustomCamelVersion(KameletMain main) throws Exception { jbangArgs.addAll(cmds); + if (verbose) { + System.out.println(jbangArgs); + } ProcessBuilder pb = new ProcessBuilder(); pb.command(jbangArgs); if (background) {