This is an automated email from the ASF dual-hosted git repository.
fmariani pushed a commit to branch camel-4.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.18.x by this push:
new 9d6ea2393ad1 Camel-JBang: Propagate --java-version option to jbang
run/debug commands
9d6ea2393ad1 is described below
commit 9d6ea2393ad1cac4b3d99a7fe5fd2590de1eaa4d
Author: Salvatore Mongiardo <[email protected]>
AuthorDate: Thu Mar 26 12:27:40 2026 +0100
Camel-JBang: Propagate --java-version option to jbang run/debug commands
---
.../modules/ROOT/pages/jbang-commands/camel-jbang-debug.adoc | 1 +
.../modules/ROOT/pages/jbang-commands/camel-jbang-run.adoc | 1 +
.../resources/META-INF/camel-jbang-commands-metadata.json | 4 ++--
.../camel/dsl/jbang/core/commands/ExportBaseCommand.java | 1 +
.../java/org/apache/camel/dsl/jbang/core/commands/Run.java | 11 +++++++++++
5 files changed, 16 insertions(+), 2 deletions(-)
diff --git
a/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-debug.adoc
b/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-debug.adoc
index e56d29f27a38..d34c6b685858 100644
--- a/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-debug.adoc
+++ b/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-debug.adoc
@@ -36,6 +36,7 @@ camel debug [options]
| `--gav` | The Maven group:artifact:version (used during exporting) | |
String
| `--health` _(deprecated)_ | Deprecated: use --observe instead. Health check
at /q/health on local HTTP server (port 8080 by default) | false | boolean
| `--ignore-loading-error` | Whether to ignore route loading and compilation
errors (use this with care!) | false | boolean
+| `--java-version` | Java version | 21 | String
| `--jfr` | Enables Java Flight Recorder saving recording to disk on exit |
false | boolean
| `--jfr-profile` | Java Flight Recorder profile to use (such as default or
profile) | | String
| `--jvm-debug` | To enable JVM remote debugging on port 4004 by default. The
supported values are true to enable the remote debugging, false to disable the
remote debugging or a number to use a custom port | | int
diff --git
a/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-run.adoc
b/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-run.adoc
index 8d5576320735..b2a0e052ad6c 100644
--- a/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-run.adoc
+++ b/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-run.adoc
@@ -34,6 +34,7 @@ camel run [options]
| `--gav` | The Maven group:artifact:version (used during exporting) | |
String
| `--health` _(deprecated)_ | Deprecated: use --observe instead. Health check
at /q/health on local HTTP server (port 8080 by default) | false | boolean
| `--ignore-loading-error` | Whether to ignore route loading and compilation
errors (use this with care!) | false | boolean
+| `--java-version` | Java version | 21 | String
| `--jfr` | Enables Java Flight Recorder saving recording to disk on exit |
false | boolean
| `--jfr-profile` | Java Flight Recorder profile to use (such as default or
profile) | | String
| `--jvm-debug` | To enable JVM remote debugging on port 4004 by default. The
supported values are true to enable the remote debugging, false to disable the
remote debugging or a number to use a custom port | | int
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/generated/resources/META-INF/camel-jbang-commands-metadata.json
b/dsl/camel-jbang/camel-jbang-core/src/generated/resources/META-INF/camel-jbang-commands-metadata.json
index 5ef23c6148f8..fa6e25822c07 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/generated/resources/META-INF/camel-jbang-commands-metadata.json
+++
b/dsl/camel-jbang/camel-jbang-core/src/generated/resources/META-INF/camel-jbang-commands-metadata.json
@@ -5,7 +5,7 @@
{ "name": "cmd", "fullName": "cmd", "description": "Performs commands in
the running Camel integrations, such as start\/stop route, or change logging
levels.", "sourceClass":
"org.apache.camel.dsl.jbang.core.commands.action.CamelAction", "options": [ {
"names": "-h,--help", "description": "Display the help and sub-commands",
"javaType": "boolean", "type": "boolean" } ], "subcommands": [ { "name":
"browse", "fullName": "cmd browse", "description": "Browse pending messages on
endpoints [...]
{ "name": "completion", "fullName": "completion", "description": "Generate
completion script for bash\/zsh", "sourceClass":
"org.apache.camel.dsl.jbang.core.commands.Complete", "options": [ { "names":
"-h,--help", "description": "Display the help and sub-commands", "javaType":
"boolean", "type": "boolean" } ] },
{ "name": "config", "fullName": "config", "description": "Get and set user
configuration values", "sourceClass":
"org.apache.camel.dsl.jbang.core.commands.config.ConfigCommand", "options": [ {
"names": "-h,--help", "description": "Display the help and sub-commands",
"javaType": "boolean", "type": "boolean" } ], "subcommands": [ { "name": "get",
"fullName": "config get", "description": "Display user configuration value",
"sourceClass": "org.apache.camel.dsl.jbang.core.commands.config. [...]
- { "name": "debug", "fullName": "debug", "description": "Debug local Camel
integration", "sourceClass": "org.apache.camel.dsl.jbang.core.commands.Debug",
"options": [ { "names": "--ago", "description": "Use ago instead of yyyy-MM-dd
HH:mm:ss in timestamp.", "javaType": "boolean", "type": "boolean" }, { "names":
"--background", "description": "Run in the background", "defaultValue":
"false", "javaType": "boolean", "type": "boolean" }, { "names":
"--background-wait", "description": "To [...]
+ { "name": "debug", "fullName": "debug", "description": "Debug local Camel
integration", "sourceClass": "org.apache.camel.dsl.jbang.core.commands.Debug",
"options": [ { "names": "--ago", "description": "Use ago instead of yyyy-MM-dd
HH:mm:ss in timestamp.", "javaType": "boolean", "type": "boolean" }, { "names":
"--background", "description": "Run in the background", "defaultValue":
"false", "javaType": "boolean", "type": "boolean" }, { "names":
"--background-wait", "description": "To [...]
{ "name": "dependency", "fullName": "dependency", "description": "Displays
all Camel dependencies required to run", "sourceClass":
"org.apache.camel.dsl.jbang.core.commands.DependencyCommand", "options": [ {
"names": "-h,--help", "description": "Display the help and sub-commands",
"javaType": "boolean", "type": "boolean" } ], "subcommands": [ { "name":
"copy", "fullName": "dependency copy", "description": "Copies all Camel
dependencies required to run to a specific directory", "sourc [...]
{ "name": "dirty", "fullName": "dirty", "description": "Check if there are
dirty files from previous Camel runs that did not terminate gracefully",
"sourceClass": "org.apache.camel.dsl.jbang.core.commands.process.Dirty",
"options": [ { "names": "--clean", "description": "Clean dirty files which are
no longer in use", "defaultValue": "false", "javaType": "boolean", "type":
"boolean" }, { "names": "-h,--help", "description": "Display the help and
sub-commands", "javaType": "boolean", " [...]
{ "name": "doc", "fullName": "doc", "description": "Shows documentation
for kamelet, component, and other Camel resources", "sourceClass":
"org.apache.camel.dsl.jbang.core.commands.catalog.CatalogDoc", "options": [ {
"names": "--camel-version", "description": "To use a different Camel version
than the default version", "javaType": "java.lang.String", "type": "string" },
{ "names": "--download", "description": "Whether to allow automatic downloading
JAR dependencies (over the internet [...]
@@ -22,7 +22,7 @@
{ "name": "nano", "fullName": "nano", "description": "Nano editor to edit
file", "sourceClass": "org.apache.camel.dsl.jbang.core.commands.Nano",
"options": [ { "names": "-h,--help", "description": "Display the help and
sub-commands", "javaType": "boolean", "type": "boolean" } ] },
{ "name": "plugin", "fullName": "plugin", "description": "Manage plugins
that add sub-commands to this CLI", "sourceClass":
"org.apache.camel.dsl.jbang.core.commands.plugin.PluginCommand", "options": [ {
"names": "-h,--help", "description": "Display the help and sub-commands",
"javaType": "boolean", "type": "boolean" } ], "subcommands": [ { "name": "add",
"fullName": "plugin add", "description": "Add new plugin", "sourceClass":
"org.apache.camel.dsl.jbang.core.commands.plugin.PluginA [...]
{ "name": "ps", "fullName": "ps", "description": "List running Camel
integrations", "sourceClass":
"org.apache.camel.dsl.jbang.core.commands.process.ListProcess", "options": [ {
"names": "--json", "description": "Output in JSON Format", "javaType":
"boolean", "type": "boolean" }, { "names": "--pid", "description": "List only
pid in the output", "javaType": "boolean", "type": "boolean" }, { "names":
"--remote", "description": "Break down counters into remote\/total pairs",
"javaType": [...]
- { "name": "run", "fullName": "run", "description": "Run as local Camel
integration", "sourceClass": "org.apache.camel.dsl.jbang.core.commands.Run",
"options": [ { "names": "--background", "description": "Run in the background",
"defaultValue": "false", "javaType": "boolean", "type": "boolean" }, { "names":
"--background-wait", "description": "To wait for run in background to startup
successfully, before returning", "defaultValue": "true", "javaType": "boolean",
"type": "boolean" }, { [...]
+ { "name": "run", "fullName": "run", "description": "Run as local Camel
integration", "sourceClass": "org.apache.camel.dsl.jbang.core.commands.Run",
"options": [ { "names": "--background", "description": "Run in the background",
"defaultValue": "false", "javaType": "boolean", "type": "boolean" }, { "names":
"--background-wait", "description": "To wait for run in background to startup
successfully, before returning", "defaultValue": "true", "javaType": "boolean",
"type": "boolean" }, { [...]
{ "name": "sbom", "fullName": "sbom", "description": "Generate a CycloneDX
or SPDX SBOM for a specific project", "sourceClass":
"org.apache.camel.dsl.jbang.core.commands.SBOMGenerator", "options": [ {
"names": "--build-property", "description": "Maven\/Gradle build properties,
ex. --build-property=prop1=foo", "javaType": "java.util.List", "type": "array"
}, { "names": "--build-tool", "description": "DEPRECATED: Build tool to use
(maven or gradle) (gradle is deprecated)", "defaultValu [...]
{ "name": "script", "fullName": "script", "description": "Run Camel
integration as shell script for terminal scripting", "sourceClass":
"org.apache.camel.dsl.jbang.core.commands.Script", "options": [ { "names":
"--logging", "description": "Can be used to turn on logging (logs to file in
<user home>\/.camel directory)", "defaultValue": "false", "javaType":
"boolean", "type": "boolean" }, { "names": "--logging-level", "description":
"Logging level ()", "defaultValue": "info", "javaType [...]
{ "name": "shell", "fullName": "shell", "description": "Interactive Camel
JBang shell.", "sourceClass": "org.apache.camel.dsl.jbang.core.commands.Shell",
"options": [ { "names": "-h,--help", "description": "Display the help and
sub-commands", "javaType": "boolean", "type": "boolean" } ] },
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
index cadd13b095a6..fa3b0b9c3799 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
@@ -383,6 +383,7 @@ public abstract class ExportBaseCommand extends
CamelCommand {
run.quarkusGroupId = quarkusGroupId;
run.springBootVersion = springBootVersion;
run.kameletsVersion = kameletsVersion;
+ run.javaVersion = javaVersion;
run.localKameletDir = localKameletDir;
run.ignoreLoadingError = ignoreLoadingError;
run.lazyBean = lazyBean;
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 218fa3e78743..ccd1532896ac 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
@@ -167,6 +167,10 @@ public class Run extends CamelCommand {
@Option(names = { "--empty" }, defaultValue = "false", description = "Run
an empty Camel without loading source files")
public boolean empty;
+ @CommandLine.Option(names = { "--java-version" },
+ description = "Java version", defaultValue = "21")
+ protected String javaVersion = "21";
+
@Option(names = { "--camel-version" }, description = "To run using a
different Camel version than the default version.")
String camelVersion;
@@ -680,6 +684,7 @@ public class Run extends CamelCommand {
writeSetting(main, profileProperties, QUARKUS_VERSION, quarkusVersion);
writeSetting(main, profileProperties, QUARKUS_GROUP_ID,
quarkusGroupId);
writeSetting(main, profileProperties, QUARKUS_ARTIFACT_ID,
quarkusArtifactId);
+ writeSetting(main, profileProperties, JAVA_VERSION, javaVersion);
// command line arguments
if (property != null) {
@@ -1148,6 +1153,7 @@ public class Run extends CamelCommand {
eq.quarkusGroupId =
PropertyResolver.fromSystemProperty(QUARKUS_GROUP_ID, () ->
this.quarkusGroupId);
eq.quarkusArtifactId =
PropertyResolver.fromSystemProperty(QUARKUS_ARTIFACT_ID, () ->
this.quarkusArtifactId);
eq.camelVersion = this.camelVersion;
+ eq.javaVersion = this.javaVersion;
eq.kameletsVersion = this.kameletsVersion;
eq.exportDir = runDirPath.toString();
eq.localKameletDir = this.localKameletDir;
@@ -1256,6 +1262,7 @@ public class Run extends CamelCommand {
eq.camelVersion = this.camelVersion;
eq.camelSpringBootVersion =
PropertyResolver.fromSystemProperty(CAMEL_SPRING_BOOT_VERSION,
() -> this.camelSpringBootVersion != null ?
this.camelSpringBootVersion : this.camelVersion);
+ eq.javaVersion = this.javaVersion;
eq.kameletsVersion = this.kameletsVersion;
eq.exportDir = runDirPath.toString();
eq.localKameletDir = this.localKameletDir;
@@ -1435,6 +1442,7 @@ public class Run extends CamelCommand {
camelVersion = answer.getProperty(CAMEL_VERSION, camelVersion);
kameletsVersion = answer.getProperty(KAMELETS_VERSION,
kameletsVersion);
springBootVersion = answer.getProperty(SPRING_BOOT_VERSION,
springBootVersion);
+ javaVersion = answer.getProperty(JAVA_VERSION, javaVersion);
quarkusGroupId = answer.getProperty(QUARKUS_GROUP_ID,
quarkusGroupId);
quarkusArtifactId = answer.getProperty(QUARKUS_ARTIFACT_ID,
quarkusArtifactId);
quarkusVersion = answer.getProperty(QUARKUS_VERSION,
quarkusVersion);
@@ -1517,6 +1525,9 @@ public class Run extends CamelCommand {
cmds.removeIf(arg -> arg.startsWith("--jvm-debug"));
}
+ if (javaVersion != null) {
+ jbangArgs.add("--java-version=" + javaVersion);
+ }
if (repositories != null) {
jbangArgs.add("--repos=" + repositories);
}