Skip to content
Merged
Show file tree
Hide file tree
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 @@ -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 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
3 changes: 2 additions & 1 deletion docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
|===
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ protected void actionTask() {
doActionBrowseTask(root);
} else if ("receive".equals(action)) {
doActionReceiveTask(root);
} else if ("readme".equals(action)) {
doActionReadmeTask(root);
} else if ("cli-debug".equals(action)) {
doActionCliDebug(root);
}
Expand All @@ -348,6 +350,26 @@ protected void actionTask() {
}
}

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");
Expand Down Expand Up @@ -1117,6 +1139,11 @@ protected void statusTask() {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ private int listExamples(String filter) {
icons.append(" ");
}
if (ExampleHelper.hasCitrusTests(entry)) {
icons.append("🧪");
icons.append("🍋");
} else {
icons.append(" ");
}
Expand All @@ -428,7 +428,7 @@ private int listExamples(String filter) {
}
printer().println();
printer().println(
" 📦 = bundled (works offline) 🌐 = online (fetched from GitHub) 🐳 = requires Docker 🧪 = Citrus tests");
" 📦 = bundled (works offline) 🌐 = online (fetched from GitHub) 🐳 = requires Docker 🍋 = Citrus tests");
printer().println();
printer().println("Usage: camel run --example=<name>");
printer().println(" camel run --example=<name> --dev");
Expand Down Expand Up @@ -910,6 +910,7 @@ private int run() throws Exception {
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) {
Expand Down Expand Up @@ -970,6 +971,10 @@ private int run() throws Exception {
// 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);
Expand Down Expand Up @@ -1070,6 +1075,12 @@ private int run() throws Exception {
} 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());
Expand Down Expand Up @@ -2216,12 +2227,6 @@ private boolean skipFile(String name) {
return true;
}

String on = FileUtil.onlyName(name, true);
on = on.toLowerCase(Locale.ROOT);
if (on.startsWith("readme")) {
return true;
}

return false;
}

Expand Down Expand Up @@ -2253,6 +2258,11 @@ private boolean jkubeFile(String name) {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"requiresDocker": false,
"hasCitrusTests": false,
"files": [
"README.adoc",
"README.md",
"application.properties",
"consumer.camel.yaml",
"producer.camel.yaml"
Expand All @@ -35,7 +35,7 @@
"requiresDocker": false,
"hasCitrusTests": true,
"files": [
"README.adoc",
"README.md",
"application.properties",
"aws-s3-cdc-log.camel.yaml",
"example-file.txt",
Expand All @@ -58,7 +58,7 @@
"requiresDocker": false,
"hasCitrusTests": true,
"files": [
"README.adoc",
"README.md",
"application.properties",
"http-to-aws-sqs.camel.yaml"
]
Expand All @@ -76,7 +76,7 @@
"requiresDocker": false,
"hasCitrusTests": false,
"files": [
"README.adoc",
"README.md",
"route.camel.yaml"
]
},
Expand All @@ -95,7 +95,7 @@
"requiresDocker": false,
"hasCitrusTests": false,
"files": [
"README.adoc",
"README.md",
"cron-log.camel.yaml"
]
},
Expand All @@ -114,7 +114,7 @@
"requiresDocker": true,
"hasCitrusTests": false,
"files": [
"README.adoc",
"README.md",
"application.properties",
"compose.yaml",
"docling-langchain4j-rag.yaml",
Expand All @@ -136,7 +136,7 @@
"requiresDocker": false,
"hasCitrusTests": false,
"files": [
"README.adoc",
"README.md",
"application.properties",
"examples/banking-sector-brief.pdf",
"examples/magnificent-seven-update.pdf",
Expand All @@ -159,7 +159,7 @@
"requiresDocker": true,
"hasCitrusTests": true,
"files": [
"README.adoc",
"README.md",
"application.properties",
"compose.yaml",
"ftp.camel.yaml",
Expand All @@ -180,7 +180,7 @@
"requiresDocker": false,
"hasCitrusTests": false,
"files": [
"README.adoc",
"README.md",
"application.properties",
"groovy.camel.yaml"
]
Expand All @@ -200,7 +200,7 @@
"requiresDocker": false,
"hasCitrusTests": false,
"files": [
"README.adoc",
"README.md",
"application.properties",
"rest-api.camel.yaml"
]
Expand All @@ -220,7 +220,7 @@
"requiresDocker": false,
"hasCitrusTests": false,
"files": [
"README.adoc",
"README.md",
"application.properties",
"rest-api.camel.yaml"
]
Expand All @@ -239,7 +239,7 @@
"requiresDocker": true,
"hasCitrusTests": true,
"files": [
"README.adoc",
"README.md",
"application.properties",
"compose.yaml",
"infra/mosquitto.conf",
Expand All @@ -262,7 +262,7 @@
"requiresDocker": false,
"hasCitrusTests": false,
"files": [
"README.adoc",
"README.md",
"application.properties",
"pii-redaction.camel.yaml",
"pii.schema.json"
Expand All @@ -282,7 +282,7 @@
"requiresDocker": false,
"hasCitrusTests": true,
"files": [
"README.adoc",
"README.md",
"application.properties",
"examples/1001.json",
"petstore-api.json",
Expand All @@ -303,7 +303,7 @@
"requiresDocker": false,
"hasCitrusTests": true,
"files": [
"README.adoc",
"README.md",
"application.properties",
"examples/pet/1000.json",
"petstore-api.json",
Expand All @@ -324,7 +324,7 @@
"requiresDocker": false,
"hasCitrusTests": false,
"files": [
"README.adoc",
"README.md",
"rest-api.camel.yaml"
]
},
Expand All @@ -343,7 +343,7 @@
"hasCitrusTests": false,
"files": [
"Greeter.java",
"README.adoc",
"README.md",
"beans.yaml",
"routes.camel.yaml"
]
Expand All @@ -363,7 +363,7 @@
"requiresDocker": false,
"hasCitrusTests": true,
"files": [
"README.adoc",
"README.md",
"analyzer/application-dev.properties",
"analyzer/error-analyzer.camel.yaml",
"containers/caches/infinispan-events-config.json",
Expand Down Expand Up @@ -410,7 +410,7 @@
"requiresDocker": true,
"hasCitrusTests": false,
"files": [
"README.adoc",
"README.md",
"application.properties",
"compose.yaml",
"sql.camel.yaml"
Expand All @@ -430,7 +430,7 @@
"requiresDocker": false,
"hasCitrusTests": false,
"files": [
"README.adoc",
"README.md",
"timer-log.camel.yaml"
]
},
Expand All @@ -448,7 +448,7 @@
"requiresDocker": false,
"hasCitrusTests": false,
"files": [
"README.adoc",
"README.md",
"consumer.camel.yaml",
"input/account.xml",
"stylesheet.xsl"
Expand Down
Loading
Loading