This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch worktree-tui8 in repository https://gitbox.apache.org/repos/asf/camel.git
commit dd475b1e9110aa1b6c05cb3209991deb4fd46bb2 Author: Claus Ibsen <[email protected]> AuthorDate: Thu May 21 13:24:57 2026 +0200 CAMEL-23572: camel-jbang: Include README files when running integrations README files (README.md, README.adoc, etc.) are no longer filtered out by camel run. They are added to the classpath and tracked via the new camel.jbang.readmeFiles property. The CLI connector exposes them in the status JSON and supports a readme action to fetch content on demand. Co-Authored-By: Claude Opus 4.6 <[email protected]> --- .../ROOT/pages/camel-4x-upgrade-guide-4_21.adoc | 4 ++++ .../modules/ROOT/pages/camel-jbang.adoc | 3 ++- .../camel/cli/connector/LocalCliConnector.java | 27 ++++++++++++++++++++++ .../camel-jbang-configuration-metadata.json | 1 + .../apache/camel/dsl/jbang/core/commands/Run.java | 22 +++++++++++++----- .../dsl/jbang/core/common/CamelJBangConstants.java | 4 ++++ 6 files changed, 54 insertions(+), 7 deletions(-) diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc index 38c45e94bc31..41c5fde63d77 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc @@ -49,6 +49,10 @@ and dev consoles for nodes inside Choice EIP branches. === camel-jbang +README files (`README.md`, `README.adoc`, etc.) are now included when running integrations with `camel run`. +Previously these files were silently excluded. The README files are added to the classpath +and exposed via the CLI connector so tools such as `camel monitor` can display them. + The `camel wrapper` command now installs the scripts as `camel` instead of `camelw`. You can use the `--command-name=camelw` to use the old name. diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc index 5d32d52f3dc0..d95a9d8160a2 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc @@ -4210,7 +4210,7 @@ The follow options related to _exporting_ or _running_, can be configured in `ap // jbang options: START === Camel JBang configurations -The camel.jbang supports 47 options, which are listed below. +The camel.jbang supports 48 options, which are listed below. [width="100%",cols="2,5,^1,2",options="header"] |=== @@ -4254,6 +4254,7 @@ The camel.jbang supports 47 options, which are listed below. | *camel.jbang.quarkusExtensionRegistryBaseUri* | The base URI of Quarkus Extension Registry | | String | *camel.jbang.quarkusGroupId* | groupId of Quarkus Platform BOM | | String | *camel.jbang.quarkusVersion* | version of Quarkus Platform BOM | | String +| *camel.jbang.readmeFiles* | README files included with the integration (Use commas to separate multiple files) | | String | *camel.jbang.repos* | Additional Maven repositories for download on-demand (Use commas to separate multiple repositories) | | String | *camel.jbang.runtime* | Which runtime to use (camel-main, spring-boot, quarkus) | | String | *camel.jbang.scriptFiles* | Additional shell script files to export to src/main/scripts directory | | String diff --git a/dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/LocalCliConnector.java b/dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/LocalCliConnector.java index 3ea9020b287b..69ef61d3fcf9 100644 --- a/dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/LocalCliConnector.java +++ b/dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/LocalCliConnector.java @@ -334,6 +334,8 @@ public class LocalCliConnector extends ServiceSupport implements CliConnector, C doActionBrowseTask(root); } else if ("receive".equals(action)) { doActionReceiveTask(root); + } else if ("readme".equals(action)) { + doActionReadmeTask(root); } else if ("cli-debug".equals(action)) { doActionCliDebug(root); } @@ -348,6 +350,26 @@ public class LocalCliConnector extends ServiceSupport implements CliConnector, C } } + private void doActionReadmeTask(JsonObject root) throws Exception { + String readmeFiles = camelContext.getPropertiesComponent() + .resolveProperty("camel.jbang.readmeFiles").orElse(null); + JsonObject json = new JsonObject(); + if (readmeFiles != null) { + String filter = root.getString("filter"); + for (String f : readmeFiles.split(",")) { + if (filter == null || f.contains(filter)) { + File file = new File(f); + if (file.isFile() && file.exists()) { + json.put("file", f); + json.put("content", Files.readString(file.toPath())); + break; + } + } + } + } + IOHelper.writeText(json.toJson(), outputFile); + } + private void doActionCliDebug(JsonObject root) { String command = root.getString("command"); String breakpoint = root.getString("breakpoint"); @@ -1117,6 +1139,11 @@ public class LocalCliConnector extends ServiceSupport implements CliConnector, C rc.put("javaVendor", mb.getVmVendor()); rc.put("javaVmName", mb.getVmName()); } + String readmeFiles = camelContext.getPropertiesComponent() + .resolveProperty("camel.jbang.readmeFiles").orElse(null); + if (readmeFiles != null) { + rc.put("readmeFiles", readmeFiles); + } root.put("runtime", rc); DevConsoleRegistry dcr = camelContext.getCamelContextExtension().getContextPlugin(DevConsoleRegistry.class); diff --git a/dsl/camel-jbang/camel-jbang-core/src/generated/resources/META-INF/camel-jbang-configuration-metadata.json b/dsl/camel-jbang/camel-jbang-core/src/generated/resources/META-INF/camel-jbang-configuration-metadata.json index 20ef3f10818a..a961aea2f78f 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/generated/resources/META-INF/camel-jbang-configuration-metadata.json +++ b/dsl/camel-jbang/camel-jbang-core/src/generated/resources/META-INF/camel-jbang-configuration-metadata.json @@ -42,6 +42,7 @@ { "name": "camel.jbang.quarkusExtensionRegistryBaseUri", "required": false, "description": "The base URI of Quarkus Extension Registry", "label": "quarkus", "type": "string", "javaType": "String", "secret": false }, { "name": "camel.jbang.quarkusGroupId", "required": false, "description": "groupId of Quarkus Platform BOM", "label": "quarkus", "type": "string", "javaType": "String", "secret": false }, { "name": "camel.jbang.quarkusVersion", "required": false, "description": "version of Quarkus Platform BOM", "label": "quarkus", "type": "string", "javaType": "String", "secret": false }, + { "name": "camel.jbang.readmeFiles", "required": false, "description": "README files included with the integration (Use commas to separate multiple files)", "type": "string", "javaType": "String", "secret": false }, { "name": "camel.jbang.repos", "required": false, "description": "Additional Maven repositories for download on-demand (Use commas to separate multiple repositories)", "label": "maven", "type": "string", "javaType": "String", "secret": false }, { "name": "camel.jbang.runtime", "required": false, "description": "Which runtime to use (camel-main, spring-boot, quarkus)", "type": "enum", "javaType": "String", "secret": false, "enum": [ "camel-main", "spring-boot", "quarkus" ] }, { "name": "camel.jbang.scriptFiles", "required": false, "description": "Additional shell script files to export to src\/main\/scripts directory", "type": "string", "javaType": "String", "secret": false }, 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 f0b64906eedf..241319e9d808 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 @@ -910,6 +910,7 @@ public class Run extends CamelCommand { StringJoiner sjTlsFiles = new StringJoiner(","); StringJoiner sjKamelets = new StringJoiner(","); StringJoiner sjJKubeFiles = new StringJoiner(","); + StringJoiner sjReadmeFiles = new StringJoiner(","); // include generated openapi to files to run if (openapi != null) { @@ -970,6 +971,10 @@ public class Run extends CamelCommand { // jkube sjJKubeFiles.add(file); continue; + } else if (isReadmeFile(file)) { + sjReadmeFiles.add(file); + sjClasspathFiles.add(file); + continue; } else if (!knownFile(file) && !file.endsWith(".properties")) { // unknown files to be added on classpath sjClasspathFiles.add(file); @@ -1070,6 +1075,12 @@ public class Run extends CamelCommand { } else { writeSetting(main, profileProperties, CLASSPATH_FILES, () -> null); } + if (sjReadmeFiles.length() > 0) { + main.addInitialProperty(README_FILES, sjReadmeFiles.toString()); + writeSettings(README_FILES, sjReadmeFiles.toString()); + } else { + writeSetting(main, profileProperties, README_FILES, () -> null); + } if (sjScriptFiles.length() > 0) { main.addInitialProperty(SCRIPT_FILES, sjScriptFiles.toString()); writeSettings(SCRIPT_FILES, sjScriptFiles.toString()); @@ -2216,12 +2227,6 @@ public class Run extends CamelCommand { return true; } - String on = FileUtil.onlyName(name, true); - on = on.toLowerCase(Locale.ROOT); - if (on.startsWith("readme")) { - return true; - } - return false; } @@ -2253,6 +2258,11 @@ public class Run extends CamelCommand { return name.endsWith(".jkube.yaml") || name.endsWith(".jkube.yml"); } + private static boolean isReadmeFile(String name) { + String on = FileUtil.onlyName(FileUtil.stripPath(name), true); + return on.toLowerCase(Locale.ROOT).startsWith("readme"); + } + private void writeSettings(String key, String value) { try { // use java.util.Properties to ensure the value is escaped correctly diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CamelJBangConstants.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CamelJBangConstants.java index feb9a6365475..96da1957be04 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CamelJBangConstants.java +++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CamelJBangConstants.java @@ -36,6 +36,10 @@ public final class CamelJBangConstants { javaType = "String") public static final String CLASSPATH_FILES = "camel.jbang.classpathFiles"; + @Metadata(description = "README files included with the integration (Use commas to separate multiple files)", + javaType = "String") + public static final String README_FILES = "camel.jbang.readmeFiles"; + @Metadata(description = "Local file directory for loading custom Kamelets", javaType = "String") public static final String LOCAL_KAMELET_DIR = "camel.jbang.localKameletDir";
