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 44c44ab7ff8f CAMEL-23658: camel-jbang - Add camel dev as alias for
camel run --dev (#23683)
44c44ab7ff8f is described below
commit 44c44ab7ff8ff42afeca49a43b503a45e3495b27
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Jun 1 22:25:22 2026 +0200
CAMEL-23658: camel-jbang - Add camel dev as alias for camel run --dev
(#23683)
Signed-off-by: Claus Ibsen <[email protected]>
Co-authored-by: Claude <[email protected]>
---
.../pages/jbang-commands/camel-jbang-commands.adoc | 1 +
.../ROOT/pages/jbang-commands/camel-jbang-dev.adoc | 86 +++++++++++++++++++++
.../META-INF/camel-jbang-commands-metadata.json | 1 +
.../dsl/jbang/core/commands/CamelJBangMain.java | 1 +
.../apache/camel/dsl/jbang/core/commands/Dev.java | 43 +++++++++++
.../camel/dsl/jbang/core/commands/DevTest.java | 88 ++++++++++++++++++++++
6 files changed, 220 insertions(+)
diff --git
a/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-commands.adoc
b/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-commands.adoc
index 007bc78d9982..c5ec871a2084 100644
---
a/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-commands.adoc
+++
b/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-commands.adoc
@@ -19,6 +19,7 @@ TIP: You can also use `camel --help` or `camel <command>
--help` to see availabl
| xref:jbang-commands/camel-jbang-config.adoc[camel config] | Get and set user
configuration values
| xref:jbang-commands/camel-jbang-debug.adoc[camel debug] | Debug local Camel
integration
| xref:jbang-commands/camel-jbang-dependency.adoc[camel dependency] | Displays
all Camel dependencies required to run
+| xref:jbang-commands/camel-jbang-dev.adoc[camel dev] | Run in dev mode with
live reload
| xref:jbang-commands/camel-jbang-dirty.adoc[camel dirty] | Check if there are
dirty files from previous Camel runs that did not terminate gracefully
| xref:jbang-commands/camel-jbang-doc.adoc[camel doc] | Shows documentation
for kamelet, component, and other Camel resources
| xref:jbang-commands/camel-jbang-doctor.adoc[camel doctor] | Checks the
environment and reports potential issues
diff --git
a/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-dev.adoc
b/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-dev.adoc
new file mode 100644
index 000000000000..b5fc0208c2b1
--- /dev/null
+++ b/docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-dev.adoc
@@ -0,0 +1,86 @@
+
+// AUTO-GENERATED by camel-package-maven-plugin - DO NOT EDIT THIS FILE
+= camel dev
+
+Run in dev mode with live reload
+
+
+== Usage
+
+[source,bash]
+----
+camel dev [options]
+----
+
+
+
+== Options
+
+[cols="2,5,1,2",options="header"]
+|===
+| Option | Description | Default | Type
+| `--background` | Run in the background | false | boolean
+| `--background-wait` | To wait for run in background to startup successfully,
before returning | true | boolean
+| `--backlog-trace` | Enables backlog tracing of the routed messages | false |
boolean
+| `--camel-spring-boot-version` | To run using a different Camel Spring Boot
version than the default version. | | String
+| `--camel-version` | To run using a different Camel version than the default
version. | | String
+| `--code` | Run the given text or file as Java DSL routes | | String
+| `--console` | Developer console at /q/dev on local HTTP server (port 8080 by
default) | false | boolean
+| `--dep,--dependency` | Add additional dependencies | | List
+| `--download` | Whether to allow automatic downloading JAR dependencies (over
the internet) | true | boolean
+| `--empty` | Run an empty Camel without loading source files | false | boolean
+| `--example` | Run an example by name, or list available examples when no
name is given. | | String
+| `--exclude` | Exclude files by name or pattern | | List
+| `--fresh` | Make sure we use fresh (i.e. non-cached) resources | false |
boolean
+| `--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` | Java version (21, 25) | 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
+| `--kamelets-version` | Apache Camel Kamelets version | | String
+| `--lazy-bean` | Whether to use lazy bean initialization (can help with
complex classloading issues) | false | boolean
+| `--local-kamelet-dir` | Local directory (or github link) for loading
Kamelets (takes precedence). Multiple directories can be specified separated by
comma. | | String
+| `--logging` | Can be used to turn off logging | true | boolean
+| `--logging-category` | Used for individual logging levels (ex:
org.apache.kafka=DEBUG) | | List
+| `--logging-color` | Use colored logging. Default is auto-detected based on
NO_COLOR, CI, FORCE_COLOR environment variables and terminal capabilities | |
boolean
+| `--logging-config-path` | Path to file with custom logging configuration |
| String
+| `--logging-json` | Use JSON logging (ECS Layout) | false | boolean
+| `--logging-level` | Logging level (ERROR, WARN, INFO, DEBUG, TRACE) | info |
String
+| `--management-port` | To use a dedicated port for HTTP management (use 0 to
dynamic assign a free random port number) | | int
+| `--maven-apache-snapshot-enabled` | Whether downloading JARs from ASF Maven
Snapshot repository is enabled | true | boolean
+| `--maven-central-enabled` | Whether downloading JARs from Maven Central
repository is enabled | true | boolean
+| `--maven-settings` | Optional location of Maven settings.xml file to
configure servers, repositories, mirrors and proxies. If set to false, not even
the default ~/.m2/settings.xml will be used. | | String
+| `--maven-settings-security` | Optional location of Maven
settings-security.xml file to decrypt settings.xml | | String
+| `--max-idle-seconds` | For how long time in seconds Camel can be idle before
stopping | 0 | int
+| `--max-messages` | Max number of messages to process before stopping | 0 |
int
+| `--max-seconds` | Max seconds to run before stopping | 0 | int
+| `--metrics` _(deprecated)_ | Deprecated: use --observe instead. Metrics
(Micrometer and Prometheus) at /q/metrics on local HTTP server (port 8080 by
default) | false | boolean
+| `--modeline` | Whether to support JBang style //DEPS to specify additional
dependencies | true | boolean
+| `--name` | The name of the Camel application | CamelJBang | String
+| `--observe` | Enable observability services | false | boolean
+| `--open-api` | Adds an OpenAPI spec from the given file (json or yaml file)
| | String
+| `--package-scan-jars` | Whether to automatic package scan JARs for custom
Spring or Quarkus beans making them available for Camel JBang | false | boolean
+| `--port` | Embeds a local HTTP server on this port (port 8080 by default;
use 0 to dynamic assign a free random port number) | | int
+| `--profile` | Profile to run (dev, test, prod). | dev | String
+| `--prompt` | Allow user to type in required parameters in prompt if not
present in application | false | boolean
+| `--prop,--property` | Additional properties (override existing) | | String
+| `--properties` | comma separated list of properties file (ex.
/path/to/file.properties,/path/to/other.properties | | String
+| `--quarkus-artifact-id` _(deprecated)_ | Deprecated. This value is not used
anymore. It is kept only for backwards compatibility and will be removed in
Camel 5.x. Camel commands may use either 'quarkus-bom' or 'quarkus-camel-bom'
artifactIds depending on the context. | quarkus-bom | String
+| `--quarkus-ext-registry` | The base URI of Quarkus Extension Registry. The
default is {@value RuntimeType#QUARKUS_EXTENSION_REGISTRY_BASE_URL} unless
camel.jbang.quarkus.platform.url system property is set (the /client/platforms
suffix is removed if present). | | String
+| `--quarkus-group-id` | groupId of Quarkus Platform BOM; honored only if
--quarkus-version is set | io.quarkus.platform | String
+| `--quarkus-version` | version of Quarkus Platform BOM; the default value is
looked up in Quarkus Extension Registry | | String
+| `--reload,--dev` | Enables dev mode (live reload when source files are
updated and saved) | | boolean
+| `--repo,--repos` | Additional maven repositories for download on-demand (Use
commas to separate multiple repositories) | | String
+| `--runtime` | Runtime (camel-main, spring-boot, quarkus) | camel-main |
RuntimeType
+| `--skip-plugins` | Skip resolving plugin dependencies | false | boolean
+| `--source-dir` | Source directory for dynamically loading Camel file(s) to
run. When using this, then files cannot be specified at the same time. | |
String
+| `--spring-boot-version` | Spring Boot version |
RuntimeType.SPRING_BOOT_VERSION | String
+| `--stub` | Stubs all the matching endpoint uri with the given component name
or pattern. Multiple names can be separated by comma. (all = stub all
endpoints). | | String
+| `--trace` | Enables trace logging of the routed messages | false | boolean
+| `--verbose` | Verbose output of startup activity (dependency resolution and
downloading | false | boolean
+| `-h,--help` | Display the help and sub-commands | | boolean
+|===
+
+
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 c03c11cf0cbf..fd70451710c6 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
@@ -8,6 +8,7 @@
{ "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": "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": "dev", "fullName": "dev", "description": "Run in dev mode with
live reload", "sourceClass": "org.apache.camel.dsl.jbang.core.commands.Dev",
"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": "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 [...]
{ "name": "doctor", "fullName": "doctor", "description": "Checks the
environment and reports potential issues", "sourceClass":
"org.apache.camel.dsl.jbang.core.commands.Doctor", "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/CamelJBangMain.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
index 5242455b5dd8..989fdd70e0cd 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
@@ -134,6 +134,7 @@ public class CamelJBangMain implements Callable<Integer> {
.addSubcommand("completion", new CommandLine(new
Complete(this)))
.addSubcommand("doc", new CommandLine(new CatalogDoc(this)))
.addSubcommand("debug", new CommandLine(new Debug(this)))
+ .addSubcommand("dev", new CommandLine(new Dev(this)))
.addSubcommand("dependency", new CommandLine(new
DependencyCommand(this))
.addSubcommand("copy", new CommandLine(new
DependencyCopy(this)))
.addSubcommand("list", new CommandLine(new
DependencyList(this)))
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Dev.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Dev.java
new file mode 100644
index 000000000000..23c8aa932cdc
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Dev.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands;
+
+import picocli.CommandLine.Command;
+
+@Command(name = "dev", description = "Run in dev mode with live reload",
sortOptions = false, showDefaultValues = true,
+ footer = {
+ "%nExamples:",
+ " camel dev",
+ " camel dev hello.yaml",
+ " camel dev --port=8080" })
+public class Dev extends Run {
+
+ public Dev(CamelJBangMain main) {
+ super(main);
+ }
+
+ @Override
+ public Integer doCall() throws Exception {
+ // always enable dev mode
+ dev = true;
+ // default to source-dir=. when no files are specified
+ if (files.isEmpty() && sourceDir == null) {
+ sourceDir = ".";
+ }
+ return super.doCall();
+ }
+}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DevTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DevTest.java
new file mode 100644
index 000000000000..146ed6fb24a1
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DevTest.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands;
+
+import org.junit.jupiter.api.Test;
+import picocli.CommandLine;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class DevTest extends CamelCommandBaseTestSupport {
+
+ @Test
+ public void shouldDefaultToDevModeWithSourceDir() throws Exception {
+ Dev command = createDev();
+ CommandLine.populateCommand(command);
+
+ // before doCall, dev is not yet set
+ assertFalse(command.dev);
+ assertNull(command.sourceDir);
+ assertTrue(command.files.isEmpty());
+
+ // simulate what doCall does before delegating to super
+ command.dev = true;
+ if (command.files.isEmpty() && command.sourceDir == null) {
+ command.sourceDir = ".";
+ }
+
+ assertTrue(command.dev);
+ assertEquals(".", command.sourceDir);
+ }
+
+ @Test
+ public void shouldNotOverrideSourceDirWhenFilesSpecified() throws
Exception {
+ Dev command = createDev();
+ CommandLine.populateCommand(command, "hello.yaml");
+
+ assertFalse(command.files.isEmpty());
+
+ // simulate what doCall does before delegating to super
+ command.dev = true;
+ if (command.files.isEmpty() && command.sourceDir == null) {
+ command.sourceDir = ".";
+ }
+
+ assertTrue(command.dev);
+ // sourceDir should remain null since files were specified
+ assertNull(command.sourceDir);
+ }
+
+ @Test
+ public void shouldRespectExplicitSourceDir() throws Exception {
+ Dev command = createDev();
+ CommandLine.populateCommand(command, "--source-dir=src/main/routes");
+
+ assertTrue(command.files.isEmpty());
+
+ // simulate what doCall does before delegating to super
+ command.dev = true;
+ if (command.files.isEmpty() && command.sourceDir == null) {
+ command.sourceDir = ".";
+ }
+
+ assertTrue(command.dev);
+ // explicit source-dir should not be overridden
+ assertEquals("src/main/routes", command.sourceDir);
+ }
+
+ private Dev createDev() {
+ return new Dev(new CamelJBangMain().withPrinter(printer));
+ }
+}