Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CAMEL-19949: camel-jbang - Add --jvm-debug-port option #11644

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down