This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch jt in repository https://gitbox.apache.org/repos/asf/camel.git
commit 0c2e8aa6430c8e3ac4e590f2ddf346fb17a45458 Author: Claus Ibsen <[email protected]> AuthorDate: Wed Aug 13 22:31:49 2025 +0200 CAMEL-22205: camel-jbang: Document all camel.jbang options for tooling --- .../modules/ROOT/pages/camel-jbang.adoc | 5 +- .../dsl/jbang/core/commands/DependencyList.java | 24 ++- .../camel/dsl/jbang/core/commands/Export.java | 47 ++-- .../dsl/jbang/core/commands/ExportBaseCommand.java | 44 ++-- .../dsl/jbang/core/commands/ExportQuarkus.java | 3 +- .../apache/camel/dsl/jbang/core/commands/Run.java | 129 +++++------ .../dsl/jbang/core/commands/SBOMGenerator.java | 25 ++- .../dsl/jbang/core/commands/TransformRoute.java | 3 +- .../dsl/jbang/core/common/CamelJBangConstants.java | 236 +++++++++++++++++++++ .../camel/dsl/jbang/core/common/RuntimeUtil.java | 2 +- .../camel/dsl/jbang/core/common/VersionHelper.java | 4 +- 11 files changed, 384 insertions(+), 138 deletions(-) diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc index 3674541605a..01dd923a5ad 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc @@ -3972,7 +3972,7 @@ The follow options related to _exporting_, can be configured in `application.pro |Apache Camel Kamelets version |`camel.jbang.localKameletDir` -|Local directory for loading Kamelets +|Local file directory for loading custom Kamelets |`camel.jbang.camelSpringBootVersion` |Camel version to use with Spring Boot @@ -4028,9 +4028,6 @@ The follow options related to _exporting_, can be configured in `application.pro |`camel.jbang.console` | Developer console at /q/dev on local HTTP server (port 8080 by default) when running standalone Camel -|`camel.jbang.info` -| Info console at /observe/info on local HTTP server (port 8080 by default) when running standalone Camel - |`camel.jbang.health` | Health check at /observe/health on local HTTP server (port 8080 by default) when running standalone Camel diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyList.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyList.java index 8890851e6ae..f7091d787df 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyList.java +++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyList.java @@ -40,6 +40,8 @@ import org.apache.camel.util.CamelCaseOrderedProperties; import org.apache.camel.util.FileUtil; import picocli.CommandLine; +import static org.apache.camel.dsl.jbang.core.common.CamelJBangConstants.*; + @CommandLine.Command(name = "list", description = "Displays all Camel dependencies required to run", sortOptions = false, showDefaultValues = true) @@ -230,21 +232,21 @@ public class DependencyList extends Export { } catch (IOException e) { // ignore } - if (this.runtime == null && prop.containsKey("camel.jbang.runtime")) { - this.runtime = RuntimeType.fromValue(prop.getProperty("camel.jbang.runtime")); + if (this.runtime == null && prop.containsKey(RUNTIME)) { + this.runtime = RuntimeType.fromValue(prop.getProperty(RUNTIME)); } if (this.gav == null) { - this.gav = prop.getProperty("camel.jbang.gav"); + this.gav = prop.getProperty(GAV); } // allow configuring versions from profile - this.javaVersion = prop.getProperty("camel.jbang.javaVersion", this.javaVersion); - this.camelVersion = prop.getProperty("camel.jbang.camelVersion", this.camelVersion); - this.kameletsVersion = prop.getProperty("camel.jbang.kameletsVersion", this.kameletsVersion); - this.localKameletDir = prop.getProperty("camel.jbang.localKameletDir", this.localKameletDir); - this.quarkusGroupId = prop.getProperty("camel.jbang.quarkusGroupId", this.quarkusGroupId); - this.quarkusArtifactId = prop.getProperty("camel.jbang.quarkusArtifactId", this.quarkusArtifactId); - this.quarkusVersion = prop.getProperty("camel.jbang.quarkusVersion", this.quarkusVersion); - this.springBootVersion = prop.getProperty("camel.jbang.springBootVersion", this.springBootVersion); + this.javaVersion = prop.getProperty(JAVA_VERSION, this.javaVersion); + this.camelVersion = prop.getProperty(CAMEL_VERSION, this.camelVersion); + this.kameletsVersion = prop.getProperty(KAMELETS_VERSION, this.kameletsVersion); + this.localKameletDir = prop.getProperty(LOCAL_KAMELET_DIR, this.localKameletDir); + this.quarkusGroupId = prop.getProperty(QUARKUS_GROUP_ID, this.quarkusGroupId); + this.quarkusArtifactId = prop.getProperty(QUARKUS_ARTIFACT_ID, this.quarkusArtifactId); + this.quarkusVersion = prop.getProperty(QUARKUS_VERSION, this.quarkusVersion); + this.springBootVersion = prop.getProperty(SPRING_BOOT_VERSION, this.springBootVersion); } // use temporary export dir diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Export.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Export.java index 7ce7e16bf99..a60ebeb99c2 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Export.java +++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Export.java @@ -26,6 +26,7 @@ import java.util.Comparator; import java.util.Date; import java.util.Properties; +import org.apache.camel.dsl.jbang.core.common.CamelJBangConstants; import org.apache.camel.dsl.jbang.core.common.RuntimeType; import org.apache.camel.dsl.jbang.core.common.RuntimeUtil; import org.apache.camel.dsl.jbang.core.common.SourceScheme; @@ -36,6 +37,8 @@ import org.apache.camel.util.FileUtil; import org.apache.camel.util.IOHelper; import picocli.CommandLine.Command; +import static org.apache.camel.dsl.jbang.core.common.CamelJBangConstants.*; + @Command(name = "export", description = "Export to other runtimes (Camel Main, Spring Boot, or Quarkus)", sortOptions = false, showDefaultValues = true) @@ -141,37 +144,37 @@ public class Export extends ExportBaseCommand { Properties props = new CamelCaseOrderedProperties(); RuntimeUtil.loadProperties(props, path); // read runtime and gav from profile if not configured - String rt = props.getProperty("camel.jbang.runtime"); + String rt = props.getProperty(CamelJBangConstants.RUNTIME); if (rt != null) { this.runtime = RuntimeType.fromValue(rt); } - this.gav = props.getProperty("camel.jbang.gav", this.gav); + this.gav = props.getProperty(GAV, this.gav); // allow configuring versions from profile - this.javaVersion = props.getProperty("camel.jbang.javaVersion", this.javaVersion); - this.camelVersion = props.getProperty("camel.jbang.camelVersion", this.camelVersion); - this.kameletsVersion = props.getProperty("camel.jbang.kameletsVersion", this.kameletsVersion); - this.localKameletDir = props.getProperty("camel.jbang.localKameletDir", this.localKameletDir); - this.quarkusGroupId = props.getProperty("camel.jbang.quarkusGroupId", this.quarkusGroupId); - this.quarkusArtifactId = props.getProperty("camel.jbang.quarkusArtifactId", this.quarkusArtifactId); - this.quarkusVersion = props.getProperty("camel.jbang.quarkusVersion", this.quarkusVersion); + this.javaVersion = props.getProperty(JAVA_VERSION, this.javaVersion); + this.camelVersion = props.getProperty(CAMEL_VERSION, this.camelVersion); + this.kameletsVersion = props.getProperty(KAMELETS_VERSION, this.kameletsVersion); + this.localKameletDir = props.getProperty(LOCAL_KAMELET_DIR, this.localKameletDir); + this.quarkusGroupId = props.getProperty(QUARKUS_GROUP_ID, this.quarkusGroupId); + this.quarkusArtifactId = props.getProperty(QUARKUS_ARTIFACT_ID, this.quarkusArtifactId); + this.quarkusVersion = props.getProperty(QUARKUS_VERSION, this.quarkusVersion); this.camelSpringBootVersion = VersionHelper.getSpringBootVersion( - () -> props.getProperty("camel.jbang.camelSpringBootVersion", this.camelSpringBootVersion)); - this.springBootVersion = props.getProperty("camel.jbang.springBootVersion", this.springBootVersion); + () -> props.getProperty(CAMEL_SPRING_BOOT_VERSION, this.camelSpringBootVersion)); + this.springBootVersion = props.getProperty(SPRING_BOOT_VERSION, this.springBootVersion); this.mavenWrapper - = "true".equals(props.getProperty("camel.jbang.mavenWrapper", this.mavenWrapper ? "true" : "false")); + = "true".equals(props.getProperty(MAVEN_WRAPPER, this.mavenWrapper ? "true" : "false")); this.gradleWrapper - = "true".equals(props.getProperty("camel.jbang.gradleWrapper", this.gradleWrapper ? "true" : "false")); - this.exportDir = props.getProperty("camel.jbang.exportDir", this.exportDir); - this.buildTool = props.getProperty("camel.jbang.buildTool", this.buildTool); - this.openapi = props.getProperty("camel.jbang.openApi", this.openapi); - this.repositories = props.getProperty("camel.jbang.repos", this.repositories); - this.mavenSettings = props.getProperty("camel.jbang.maven-settings", this.mavenSettings); - this.mavenSettingsSecurity = props.getProperty("camel.jbang.maven-settings-security", this.mavenSettingsSecurity); + = "true".equals(props.getProperty(GRADLE_WRAPPER, this.gradleWrapper ? "true" : "false")); + this.exportDir = props.getProperty(EXPORT_DIR, this.exportDir); + this.buildTool = props.getProperty(BUILD_TOOL, this.buildTool); + this.openapi = props.getProperty(OPEN_API, this.openapi); + this.repositories = props.getProperty(REPOS, this.repositories); + this.mavenSettings = props.getProperty(MAVEN_SETTINGS, this.mavenSettings); + this.mavenSettingsSecurity = props.getProperty(MAVEN_SETTINGS_SECURITY, this.mavenSettingsSecurity); this.mavenCentralEnabled = "true" - .equals(props.getProperty("camel.jbang.maven-central-enabled", mavenCentralEnabled ? "true" : "false")); - this.mavenApacheSnapshotEnabled = "true".equals(props.getProperty("camel.jbang.maven-apache-snapshot-enabled", + .equals(props.getProperty(MAVEN_CENTRAL_ENABLED, mavenCentralEnabled ? "true" : "false")); + this.mavenApacheSnapshotEnabled = "true".equals(props.getProperty(MAVEN_APACHE_SNAPSHOTS, mavenApacheSnapshotEnabled ? "true" : "false")); - this.excludes = RuntimeUtil.getCommaSeparatedPropertyAsList(props, "camel.jbang.excludes", this.excludes); + this.excludes = RuntimeUtil.getCommaSeparatedPropertyAsList(props, EXCLUDES, this.excludes); } } 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 f8afb46c95b..3429a14c0c6 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 @@ -69,6 +69,8 @@ import org.apache.camel.util.IOHelper; import org.apache.camel.util.StringHelper; import picocli.CommandLine; +import static org.apache.camel.dsl.jbang.core.common.CamelJBangConstants.*; + public abstract class ExportBaseCommand extends CamelCommand { protected static final String BUILD_DIR = CommandLineHelper.CAMEL_JBANG_WORK_DIR + "/work"; @@ -77,12 +79,12 @@ public abstract class ExportBaseCommand extends CamelCommand { "camel.main.routesIncludePattern", "camel.component.properties.location", "camel.component.kamelet.location", - "camel.jbang.classpathFiles", - "camel.jbang.localKameletDir", - "camel.jbang.groovyFiles", - "camel.jbang.scriptFiles", - "camel.jbang.tlsFiles", - "camel.jbang.jkubeFiles", + CLASSPATH_FILES, + LOCAL_KAMELET_DIR, + GROOVY_FILES, + SCRIPT_FILES, + TLS_FILES, + JKUBE_FILES, "kamelet" }; @@ -485,8 +487,8 @@ public abstract class ExportBaseCommand extends CamelCommand { } } } - } else if (line.startsWith("camel.jbang.dependencies=")) { - String deps = StringHelper.after(line, "camel.jbang.dependencies="); + } else if (line.startsWith(DEPENDENCIES + "=")) { + String deps = StringHelper.after(line, DEPENDENCIES + "="); if (!deps.isEmpty()) { for (String d : deps.split(",")) { answer.add(d.trim()); @@ -503,8 +505,8 @@ public abstract class ExportBaseCommand extends CamelCommand { } } } - } else if (line.startsWith("camel.jbang.classpathFiles")) { - String deps = StringHelper.after(line, "camel.jbang.classpathFiles="); + } else if (line.startsWith(CLASSPATH_FILES + "=")) { + String deps = StringHelper.after(line, CLASSPATH_FILES + "="); if (!deps.isEmpty()) { for (String d : deps.split(",")) { // special to include local JARs in export lib folder @@ -621,7 +623,7 @@ public abstract class ExportBaseCommand extends CamelCommand { Properties prop = new CamelCaseOrderedProperties(); RuntimeUtil.loadProperties(prop, settings); - String localKameletDir = prop.getProperty("camel.jbang.localKameletDir"); + String localKameletDir = prop.getProperty(LOCAL_KAMELET_DIR); if (localKameletDir != null) { String scheme = getScheme(localKameletDir); if (scheme != null) { @@ -659,12 +661,12 @@ public abstract class ExportBaseCommand extends CamelCommand { } boolean java = "java".equals(ext); boolean kamelet = "kamelet".equals(k) || "camel.component.kamelet.location".equals(k) - || "camel.jbang.localKameletDir".equals(k) || "kamelet.yaml".equalsIgnoreCase(ext2); + || LOCAL_KAMELET_DIR.equals(k) || "kamelet.yaml".equalsIgnoreCase(ext2); boolean camel = !kamelet && "camel.main.routesIncludePattern".equals(k); - boolean jkube = "camel.jbang.jkubeFiles".equals(k); - boolean script = "camel.jbang.scriptFiles".equals(k); - boolean groovy = "camel.jbang.groovyFiles".equals(k); - boolean tls = "camel.jbang.tlsFiles".equals(k); + boolean jkube = JKUBE_FILES.equals(k); + boolean script = SCRIPT_FILES.equals(k); + boolean groovy = GROOVY_FILES.equals(k); + boolean tls = TLS_FILES.equals(k); boolean web = ext != null && List.of("css", "html", "ico", "jpeg", "jpg", "js", "png").contains(ext); Path targetDir; if (java) { @@ -957,7 +959,7 @@ public abstract class ExportBaseCommand extends CamelCommand { protected String getMavenRepositories(Path settings, Properties prop, String camelVersion) throws Exception { Set<String> answer = new LinkedHashSet<>(); - String propRepositories = prop.getProperty("camel.jbang.repositories"); + String propRepositories = prop.getProperty(CLASSPATH_FILES); if (propRepositories != null) { answer.add(propRepositories); } @@ -1025,12 +1027,12 @@ public abstract class ExportBaseCommand extends CamelCommand { protected static String jibMavenPluginVersion(Path settings, Properties prop) { String answer = null; if (prop != null) { - answer = prop.getProperty("camel.jbang.jib-maven-plugin-version"); + answer = prop.getProperty(JIB_MAVEN_PLUGIN_VERSION); } if (answer == null) { try { List<String> lines = RuntimeUtil.loadPropertiesLines(settings); - answer = lines.stream().filter(l -> l.startsWith("camel.jbang.jib-maven-plugin-version=")) + answer = lines.stream().filter(l -> l.startsWith(JIB_MAVEN_PLUGIN_VERSION + "=")) .map(s -> StringHelper.after(s, "=")).findFirst().orElse(null); } catch (Exception e) { // ignore @@ -1042,13 +1044,13 @@ public abstract class ExportBaseCommand extends CamelCommand { protected static String jkubeMavenPluginVersion(Path settings, Properties props) { String answer = null; if (props != null) { - answer = props.getProperty("camel.jbang.jkube-maven-plugin-version"); + answer = props.getProperty(JKUBE_MAVEN_PLUGIN_VERSION); } if (answer == null) { try { List<String> lines = RuntimeUtil.loadPropertiesLines(settings); answer = lines.stream() - .filter(l -> l.startsWith("camel.jbang.jkube-maven-plugin-version=") || l.startsWith("jkube.version=")) + .filter(l -> l.startsWith(JKUBE_MAVEN_PLUGIN_VERSION + "=") || l.startsWith("jkube.version=")) .map(s -> StringHelper.after(s, "=")).findFirst().orElse(null); } catch (Exception e) { // ignore diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportQuarkus.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportQuarkus.java index b96dd2b260a..28574e60132 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportQuarkus.java +++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportQuarkus.java @@ -44,6 +44,7 @@ import org.apache.camel.util.IOHelper; import org.apache.camel.util.StringHelper; import static org.apache.camel.dsl.jbang.core.commands.ExportHelper.exportPackageName; +import static org.apache.camel.dsl.jbang.core.common.CamelJBangConstants.*; class ExportQuarkus extends Export { @@ -186,7 +187,7 @@ class ExportQuarkus extends Export { sj.add(v); } // extra classpath files - if ("camel.jbang.classpathFiles".equals(k)) { + if (CLASSPATH_FILES.equals(k)) { v = Arrays.stream(v.split(",")) .filter(d -> !d.endsWith(".jar")) // skip local lib JARs .map(ExportQuarkus::stripPath) // remove scheme 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 fa3a84dd8bc..5d25b720d69 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 @@ -75,6 +75,7 @@ import picocli.CommandLine.Parameters; import static org.apache.camel.dsl.jbang.core.common.CamelCommandHelper.CAMEL_INSTANCE_TYPE; import static org.apache.camel.dsl.jbang.core.common.CamelCommandHelper.extractState; +import static org.apache.camel.dsl.jbang.core.common.CamelJBangConstants.*; import static org.apache.camel.dsl.jbang.core.common.GistHelper.asGistSingleUrl; import static org.apache.camel.dsl.jbang.core.common.GistHelper.fetchGistUrls; import static org.apache.camel.dsl.jbang.core.common.GitHubHelper.asGithubSingleUrl; @@ -331,7 +332,7 @@ public class Run extends CamelCommand { protected boolean ignoreLoadingError; @Option(names = { "--lazy-bean" }, defaultValue = "false", - description = "Whether to use lazy bean initialization (can help with complex classloading issues") + description = "Whether to use lazy bean initialization (can help with complex classloading issues)") protected boolean lazyBean; @Option(names = { "--prompt" }, defaultValue = "false", @@ -600,7 +601,7 @@ public class Run extends CamelCommand { sj.add(n); } stub = sj.toString(); - writeSetting(main, profileProperties, "camel.jbang.stub", stub); + writeSetting(main, profileProperties, STUB, stub); main.setStubPattern(stub); } @@ -610,7 +611,7 @@ public class Run extends CamelCommand { writeSetting(main, profileProperties, "camel.main.shutdownTimeout", "5"); } if (sourceDir != null) { - writeSetting(main, profileProperties, "camel.jbang.sourceDir", sourceDir); + writeSetting(main, profileProperties, SOURCE_DIR, sourceDir); } if (trace) { writeSetting(main, profileProperties, "camel.main.tracing", "true"); @@ -621,37 +622,37 @@ public class Run extends CamelCommand { main.configure().withModeline(true); } if (ignoreLoadingError) { - writeSetting(main, profileProperties, "camel.jbang.ignoreLoadingError", "true"); + writeSetting(main, profileProperties, IGNORE_LOADING_ERROR, "true"); } if (lazyBean) { - writeSetting(main, profileProperties, "camel.jbang.lazyBean", "true"); + writeSetting(main, profileProperties, LAZY_BEAN, "true"); } if (prompt) { - writeSetting(main, profileProperties, "camel.jbang.prompt", "true"); + writeSetting(main, profileProperties, PROMPT, "true"); } - writeSetting(main, profileProperties, "camel.jbang.compileWorkDir", + writeSetting(main, profileProperties, COMPILE_WORK_DIR, Paths.get(CommandLineHelper.CAMEL_JBANG_WORK_DIR, "compile").toString()); if (gav != null) { - writeSetting(main, profileProperties, "camel.jbang.gav", gav); + writeSetting(main, profileProperties, GAV, gav); } - writeSetting(main, profileProperties, "camel.jbang.open-api", openapi); + writeSetting(main, profileProperties, OPEN_API, openapi); if (repositories != null) { - writeSetting(main, profileProperties, "camel.jbang.repos", repositories); + writeSetting(main, profileProperties, REPOS, repositories); } - writeSetting(main, profileProperties, "camel.jbang.health", health ? "true" : "false"); - writeSetting(main, profileProperties, "camel.jbang.metrics", metrics ? "true" : "false"); - writeSetting(main, profileProperties, "camel.jbang.console", console ? "true" : "false"); - writeSetting(main, profileProperties, "camel.jbang.verbose", verbose ? "true" : "false"); + writeSetting(main, profileProperties, HEALTH, health ? "true" : "false"); + writeSetting(main, profileProperties, METRICS, metrics ? "true" : "false"); + writeSetting(main, profileProperties, CONSOLE, console ? "true" : "false"); + writeSetting(main, profileProperties, VERBOSE, verbose ? "true" : "false"); // the runtime version of Camel is what is loaded via the catalog - writeSetting(main, profileProperties, "camel.jbang.camel-version", new DefaultCamelCatalog().getCatalogVersion()); - writeSetting(main, profileProperties, "camel.jbang.springBootVersion", springBootVersion); - writeSetting(main, profileProperties, "camel.jbang.quarkusVersion", quarkusVersion); - writeSetting(main, profileProperties, "camel.jbang.quarkusGroupId", quarkusGroupId); - writeSetting(main, profileProperties, "camel.jbang.quarkusArtifactId", quarkusArtifactId); + writeSetting(main, profileProperties, CAMEL_VERSION, new DefaultCamelCatalog().getCatalogVersion()); + writeSetting(main, profileProperties, SPRING_BOOT_VERSION, springBootVersion); + writeSetting(main, profileProperties, QUARKUS_VERSION, quarkusVersion); + writeSetting(main, profileProperties, QUARKUS_GROUP_ID, quarkusGroupId); + writeSetting(main, profileProperties, QUARKUS_ARTIFACT_ID, quarkusArtifactId); if (observe) { - main.addInitialProperty("camel.jbang.dependencies", "camel:observability-services"); + main.addInitialProperty(DEPENDENCIES, "camel:observability-services"); } // command line arguments @@ -670,14 +671,14 @@ public class Run extends CamelCommand { if (!verbose) { main.setSilent(true); } - main.addInitialProperty("camel.jbang.export", "true"); + main.addInitialProperty(EXPORT, "true"); // enable stub in silent mode so we do not use real components main.setStubPattern("*"); // do not run for very long in silent run main.addInitialProperty("camel.main.autoStartup", "false"); main.addInitialProperty("camel.main.durationMaxSeconds", "-1"); } else if (debugRun) { - main.addInitialProperty("camel.jbang.debug", "true"); + main.addInitialProperty(DEBUG, "true"); } else if (transformRun) { main.setSilent(true); // enable stub in silent mode so we do not use real components @@ -706,10 +707,10 @@ public class Run extends CamelCommand { if (managementPort != -1) { writeSetting(main, profileProperties, "camel.management.port", () -> String.valueOf(managementPort)); } - writeSetting(main, profileProperties, "camel.jbang.jfr", jfr || jfrProfile != null ? "jfr" : null); - writeSetting(main, profileProperties, "camel.jbang.jfr-profile", jfrProfile != null ? jfrProfile : null); + writeSetting(main, profileProperties, JFR, jfr || jfrProfile != null ? "jfr" : null); + writeSetting(main, profileProperties, JFR_PROFILE, jfrProfile != null ? jfrProfile : null); - writeSetting(main, profileProperties, "camel.jbang.kameletsVersion", kameletsVersion); + writeSetting(main, profileProperties, KAMELETS_VERSION, kameletsVersion); StringJoiner js = new StringJoiner(","); StringJoiner sjReload = new StringJoiner(","); @@ -867,34 +868,34 @@ public class Run extends CamelCommand { writeSetting(main, profileProperties, "camel.main.routesIncludePattern", () -> null); } if (sjClasspathFiles.length() > 0) { - main.addInitialProperty("camel.jbang.classpathFiles", sjClasspathFiles.toString()); - writeSettings("camel.jbang.classpathFiles", sjClasspathFiles.toString()); + main.addInitialProperty(CLASSPATH_FILES, sjClasspathFiles.toString()); + writeSettings(CLASSPATH_FILES, sjClasspathFiles.toString()); } else { - writeSetting(main, profileProperties, "camel.jbang.classpathFiles", () -> null); + writeSetting(main, profileProperties, CLASSPATH_FILES, () -> null); } if (sjScriptFiles.length() > 0) { - main.addInitialProperty("camel.jbang.scriptFiles", sjScriptFiles.toString()); - writeSettings("camel.jbang.scriptFiles", sjScriptFiles.toString()); + main.addInitialProperty(SCRIPT_FILES, sjScriptFiles.toString()); + writeSettings(SCRIPT_FILES, sjScriptFiles.toString()); } else { - writeSetting(main, profileProperties, "camel.jbang.scriptFiles", () -> null); + writeSetting(main, profileProperties, SCRIPT_FILES, () -> null); } if (sjGroovyFiles.length() > 0) { - main.addInitialProperty("camel.jbang.groovyFiles", sjGroovyFiles.toString()); - writeSettings("camel.jbang.groovyFiles", sjGroovyFiles.toString()); + main.addInitialProperty(GROOVY_FILES, sjGroovyFiles.toString()); + writeSettings(GROOVY_FILES, sjGroovyFiles.toString()); } else { - writeSetting(main, profileProperties, "camel.jbang.groovyFiles", () -> null); + writeSetting(main, profileProperties, GROOVY_FILES, () -> null); } if (sjTlsFiles.length() > 0) { - main.addInitialProperty("camel.jbang.tlsFiles", sjTlsFiles.toString()); - writeSettings("camel.jbang.tlsFiles", sjTlsFiles.toString()); + main.addInitialProperty(TLS_FILES, sjTlsFiles.toString()); + writeSettings(TLS_FILES, sjTlsFiles.toString()); } else { - writeSetting(main, profileProperties, "camel.jbang.tlsFiles", () -> null); + writeSetting(main, profileProperties, TLS_FILES, () -> null); } if (sjJKubeFiles.length() > 0) { - main.addInitialProperty("camel.jbang.jkubeFiles", sjJKubeFiles.toString()); - writeSettings("camel.jbang.jkubeFiles", sjJKubeFiles.toString()); + main.addInitialProperty(JKUBE_FILES, sjJKubeFiles.toString()); + writeSettings(JKUBE_FILES, sjJKubeFiles.toString()); } else { - writeSetting(main, profileProperties, "camel.jbang.jkubeFiles", () -> null); + writeSetting(main, profileProperties, JKUBE_FILES, () -> null); } if (sjKamelets.length() > 0) { @@ -955,8 +956,8 @@ public class Run extends CamelCommand { addDependencies(RuntimeUtil.getDependenciesAsArray(profileProperties)); if (!dependencies.isEmpty()) { var joined = String.join(",", dependencies); - main.addInitialProperty("camel.jbang.dependencies", joined); - writeSettings("camel.jbang.dependencies", joined); + main.addInitialProperty(DEPENDENCIES, joined); + writeSettings(DEPENDENCIES, joined); } // if we have a specific camel version then make sure we really need to switch @@ -1257,7 +1258,7 @@ public class Run extends CamelCommand { if (dev && (sourceDir != null || sjReload.length() > 0)) { main.addInitialProperty("camel.main.routesReloadEnabled", "true"); if (sourceDir != null) { - main.addInitialProperty("camel.jbang.sourceDir", sourceDir); + main.addInitialProperty(SOURCE_DIR, sourceDir); main.addInitialProperty("camel.main.routesReloadDirectory", sourceDir); main.addInitialProperty("camel.main.routesReloadPattern", "*"); main.addInitialProperty("camel.main.routesReloadDirectoryRecursive", "true"); @@ -1333,29 +1334,29 @@ public class Run extends CamelCommand { = "true".equals(answer.getProperty("loggingColor", loggingColor ? "true" : "false")); loggingJson = "true".equals(answer.getProperty("loggingJson", loggingJson ? "true" : "false")); - repositories = answer.getProperty("camel.jbang.repos", repositories); - mavenSettings = answer.getProperty("camel.jbang.maven-settings", mavenSettings); - mavenSettingsSecurity = answer.getProperty("camel.jbang.maven-settings-security", mavenSettingsSecurity); + repositories = answer.getProperty(REPOS, repositories); + mavenSettings = answer.getProperty(MAVEN_SETTINGS, mavenSettings); + mavenSettingsSecurity = answer.getProperty(MAVEN_SETTINGS_SECURITY, mavenSettingsSecurity); mavenCentralEnabled = "true" - .equals(answer.getProperty("camel.jbang.maven-central-enabled", mavenCentralEnabled ? "true" : "false")); - mavenApacheSnapshotEnabled = "true".equals(answer.getProperty("camel.jbang.maven-apache-snapshot-enabled", + .equals(answer.getProperty(MAVEN_CENTRAL_ENABLED, mavenCentralEnabled ? "true" : "false")); + mavenApacheSnapshotEnabled = "true".equals(answer.getProperty(MAVEN_APACHE_SNAPSHOTS, mavenApacheSnapshotEnabled ? "true" : "false")); - openapi = answer.getProperty("camel.jbang.open-api", openapi); - download = "true".equals(answer.getProperty("camel.jbang.download", download ? "true" : "false")); + openapi = answer.getProperty(OPEN_API, openapi); + download = "true".equals(answer.getProperty(DOWNLOAD, download ? "true" : "false")); packageScanJars - = "true".equals(answer.getProperty("camel.jbang.packageScanJars", packageScanJars ? "true" : "false")); - background = "true".equals(answer.getProperty("camel.jbang.background", background ? "true" : "false")); - backgroundWait = "true".equals(answer.getProperty("camel.jbang.backgroundWait", backgroundWait ? "true" : "false")); - jvmDebugPort = parseJvmDebugPort(answer.getProperty("camel.jbang.jvmDebug", Integer.toString(jvmDebugPort))); - camelVersion = answer.getProperty("camel.jbang.camel-version", camelVersion); - kameletsVersion = answer.getProperty("camel.jbang.kameletsVersion", kameletsVersion); - springBootVersion = answer.getProperty("camel.jbang.springBootVersion", springBootVersion); - quarkusGroupId = answer.getProperty("camel.jbang.quarkusGroupId", quarkusGroupId); - quarkusArtifactId = answer.getProperty("camel.jbang.quarkusArtifactId", quarkusArtifactId); - quarkusVersion = answer.getProperty("camel.jbang.quarkusVersion", quarkusVersion); - gav = answer.getProperty("camel.jbang.gav", gav); - stub = answer.getProperty("camel.jbang.stub", stub); - excludes = RuntimeUtil.getCommaSeparatedPropertyAsList(answer, "camel.jbang.excludes", excludes); + = "true".equals(answer.getProperty(PACKAGE_SCAN_JARS, packageScanJars ? "true" : "false")); + background = "true".equals(answer.getProperty(BACKGROUND, background ? "true" : "false")); + backgroundWait = "true".equals(answer.getProperty(BACKGROUND_WAIT, backgroundWait ? "true" : "false")); + jvmDebugPort = parseJvmDebugPort(answer.getProperty(JVM_DEBUG, Integer.toString(jvmDebugPort))); + camelVersion = answer.getProperty(CAMEL_VERSION, camelVersion); + kameletsVersion = answer.getProperty(KAMELETS_VERSION, kameletsVersion); + springBootVersion = answer.getProperty(SPRING_BOOT_VERSION, springBootVersion); + quarkusGroupId = answer.getProperty(QUARKUS_GROUP_ID, quarkusGroupId); + quarkusArtifactId = answer.getProperty(QUARKUS_ARTIFACT_ID, quarkusArtifactId); + quarkusVersion = answer.getProperty(QUARKUS_VERSION, quarkusVersion); + gav = answer.getProperty(GAV, gav); + stub = answer.getProperty(STUB, stub); + excludes = RuntimeUtil.getCommaSeparatedPropertyAsList(answer, EXCLUDES, excludes); } return answer; @@ -1768,7 +1769,7 @@ public class Run extends CamelCommand { sj.add(part); } main = new KameletMain(CAMEL_INSTANCE_TYPE, sj.toString()); - writeSettings("camel.jbang.localKameletDir", sj.toString()); + writeSettings(LOCAL_KAMELET_DIR, sj.toString()); } return main; } diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/SBOMGenerator.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/SBOMGenerator.java index 7087333b9ec..826e9bad392 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/SBOMGenerator.java +++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/SBOMGenerator.java @@ -22,6 +22,7 @@ import java.nio.file.Paths; import java.util.Properties; import java.util.concurrent.TimeUnit; +import org.apache.camel.dsl.jbang.core.common.CamelJBangConstants; import org.apache.camel.dsl.jbang.core.common.CommandLineHelper; import org.apache.camel.dsl.jbang.core.common.RuntimeType; import org.apache.camel.dsl.jbang.core.common.RuntimeUtil; @@ -29,6 +30,8 @@ import org.apache.camel.util.CamelCaseOrderedProperties; import org.apache.camel.util.FileUtil; import picocli.CommandLine; +import static org.apache.camel.dsl.jbang.core.common.CamelJBangConstants.*; + @CommandLine.Command(name = "sbom", description = "Generate a CycloneDX or SPDX SBOM for a specific project", sortOptions = false, showDefaultValues = true) @@ -165,21 +168,21 @@ public class SBOMGenerator extends Export { if (Files.exists(profile)) { Properties prop = new CamelCaseOrderedProperties(); RuntimeUtil.loadProperties(prop, profile); - if (this.runtime == null && prop.containsKey("camel.jbang.runtime")) { - this.runtime = RuntimeType.fromValue(prop.getProperty("camel.jbang.runtime")); + if (this.runtime == null && prop.containsKey(CamelJBangConstants.RUNTIME)) { + this.runtime = RuntimeType.fromValue(prop.getProperty(CamelJBangConstants.RUNTIME)); } if (this.gav == null) { - this.gav = prop.getProperty("camel.jbang.gav"); + this.gav = prop.getProperty(GAV); } // allow configuring versions from profile - this.javaVersion = prop.getProperty("camel.jbang.javaVersion", this.javaVersion); - this.camelVersion = prop.getProperty("camel.jbang.camelVersion", this.camelVersion); - this.kameletsVersion = prop.getProperty("camel.jbang.kameletsVersion", this.kameletsVersion); - this.localKameletDir = prop.getProperty("camel.jbang.localKameletDir", this.localKameletDir); - this.quarkusGroupId = prop.getProperty("camel.jbang.quarkusGroupId", this.quarkusGroupId); - this.quarkusArtifactId = prop.getProperty("camel.jbang.quarkusArtifactId", this.quarkusArtifactId); - this.quarkusVersion = prop.getProperty("camel.jbang.quarkusVersion", this.quarkusVersion); - this.springBootVersion = prop.getProperty("camel.jbang.springBootVersion", this.springBootVersion); + this.javaVersion = prop.getProperty(JAVA_VERSION, this.javaVersion); + this.camelVersion = prop.getProperty(CAMEL_VERSION, this.camelVersion); + this.kameletsVersion = prop.getProperty(KAMELETS_VERSION, this.kameletsVersion); + this.localKameletDir = prop.getProperty(LOCAL_KAMELET_DIR, this.localKameletDir); + this.quarkusGroupId = prop.getProperty(QUARKUS_GROUP_ID, this.quarkusGroupId); + this.quarkusArtifactId = prop.getProperty(QUARKUS_ARTIFACT_ID, this.quarkusArtifactId); + this.quarkusVersion = prop.getProperty(QUARKUS_VERSION, this.quarkusVersion); + this.springBootVersion = prop.getProperty(SPRING_BOOT_VERSION, this.springBootVersion); } // use temporary export dir diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/TransformRoute.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/TransformRoute.java index 2076b260bde..4ae62e8d283 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/TransformRoute.java +++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/TransformRoute.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Stack; +import org.apache.camel.dsl.jbang.core.common.CamelJBangConstants; import org.apache.camel.dsl.jbang.core.common.CommandLineHelper; import org.apache.camel.main.KameletMain; import org.apache.camel.util.IOHelper; @@ -92,7 +93,7 @@ public class TransformRoute extends CamelCommand { main.addInitialProperty("camel.main.dumpRoutesResolvePlaceholders", Boolean.toString(resolvePlaceholders)); main.addInitialProperty("camel.main.dumpRoutesUriAsParameters", Boolean.toString(uriAsParameters)); main.addInitialProperty("camel.main.dumpRoutesOutput", target); - main.addInitialProperty("camel.jbang.transform", "true"); + main.addInitialProperty(CamelJBangConstants.TRANSFORM, "true"); main.addInitialProperty("camel.component.properties.ignoreMissingProperty", "true"); if (ignoreLoadingError) { // turn off bean method validator if ignore loading error 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 new file mode 100644 index 00000000000..8814058f538 --- /dev/null +++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CamelJBangConstants.java @@ -0,0 +1,236 @@ +/* + * 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.common; + +import org.apache.camel.spi.Metadata; + +/** + * Common set of camel.jbang.xxx configuration options that can be defined in application.properties to control running + * and exporting commands. + */ +public final class CamelJBangConstants { + + @Metadata(description = "Additional files to add to classpath (Use commas to separate multiple files).", + javaType = "String") + public static final String CLASSPATH_FILES = "camel.jbang.classpathFiles"; + + @Metadata(description = "Local file directory for loading custom Kamelets", + javaType = "String") + public static final String LOCAL_KAMELET_DIR = "camel.jbang.localKameletDir"; + + @Metadata(description = "Additional groovy source files to export to src/main/resources/camel-groovy directory (Use commas to separate multiple files)", + javaType = "String") + public static final String GROOVY_FILES = "camel.jbang.groovyFiles"; + + @Metadata(description = "Additional shell script files to export to src/main/scripts directory", + javaType = "String") + public static final String SCRIPT_FILES = "camel.jbang.scriptFiles"; + + @Metadata(description = "Additional SSL/TLS files to export to src/main/tls directory", + javaType = "String") + public static final String TLS_FILES = "camel.jbang.tlsFiles"; + + @Metadata(description = "Resource YAML fragments for Kubernetes using Eclipse JKube tool (Use commas to separate multiple files).", + javaType = "String", label = "kubernetes") + public static final String JKUBE_FILES = "camel.jbang.jkubeFiles"; + + @Metadata(description = "Which runtime to use (camel-main, spring-boot, quarkus)", + javaType = "String", enums = "camel-main,spring-boot,quarkus") + public static final String RUNTIME = "camel.jbang.runtime"; + + @Metadata(description = "Maven coordinate (groupId:artifactId:version)", + javaType = "String") + public static final String GAV = "camel.jbang.gav"; + + @Metadata(description = "Java version (17 or 21)", + javaType = "String", enums = "17,21", defaultValue = "21") + public static final String JAVA_VERSION = "camel.jbang.javaVersion"; + + @Metadata(description = "Apache Camel Kamelets version. By default the Kamelets are the same version as Camel.", + javaType = "String") + public static final String KAMELETS_VERSION = "camel.jbang.kameletsVersion"; + + @Metadata(description = "Quarkus Platform Maven groupId", + javaType = "String", label = "quarkus") + public static final String QUARKUS_GROUP_ID = "camel.jbang.quarkusGroupId"; + + @Metadata(description = "Quarkus Platform Maven artifactId", + javaType = "String", label = "quarkus") + public static final String QUARKUS_ARTIFACT_ID = "camel.jbang.quarkusArtifactId"; + + @Metadata(description = "Quarkus Platform version", + javaType = "String", label = "quarkus") + public static final String QUARKUS_VERSION = "camel.jbang.quarkusVersion"; + + @Metadata(description = "Spring Boot version", + javaType = "String", label = "spring-boot") + public static final String SPRING_BOOT_VERSION = "camel.jbang.springBootVersion"; + + @Metadata(description = "Include Maven Wrapper files in the exported project", + javaType = "boolean", defaultValue = "true") + public static final String MAVEN_WRAPPER = "camel.jbang.mavenWrapper"; + + @Metadata(description = "Include Gradle Wrapper files in the exported project", + javaType = "boolean", defaultValue = "true") + public static final String GRADLE_WRAPPER = "camel.jbang.gradleWrapper"; + + @Metadata(description = "Build tool to use (Maven or Gradle)", + javaType = "String", defaultValue = "Maven") + public static final String BUILD_TOOL = "camel.jbang.buildTool"; + + @Metadata(description = "Directory where the project will be exported", + javaType = "String", defaultValue = ".") + public static final String EXPORT_DIR = "camel.jbang.exportDir"; + + @Metadata(description = "File name of open-api spec file (JSON or YAML) to generate routes from the swagger/openapi API spec file.", + javaType = "String") + public static final String OPEN_API = "camel.jbang.openApi"; + + @Metadata(description = "Additional Maven repositories for download on-demand (Use commas to separate multiple repositories)", + javaType = "String", label = "maven") + public static final String REPOS = "camel.jbang.repos"; + + @Metadata(description = "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.", + javaType = "String", label = "maven") + public static final String MAVEN_SETTINGS = "camel.jbang.maven-settings"; + + @Metadata(description = "Optional location of Maven settings-security.xml file to decrypt Maven Settings (settings.xml) file", + javaType = "String", label = "maven") + public static final String MAVEN_SETTINGS_SECURITY = "camel.jbang.maven-settings-security"; + + @Metadata(description = "Whether downloading JARs from Maven Central repository is enabled", + javaType = "boolean", defaultValue = "true", label = "maven") + public static final String MAVEN_CENTRAL_ENABLED = "camel.jbang.maven-central-enabled"; + + @Metadata(description = "Whether downloading JARs from ASF Maven Snapshot repository is enabled", + javaType = "boolean", defaultValue = "true", label = "maven") + public static final String MAVEN_APACHE_SNAPSHOTS = "camel.jbang.maven-apache-snapshot-enabled"; + + @Metadata(description = "Exclude files by name or pattern (Use commas to separate multiple files)", + javaType = "String") + public static final String EXCLUDES = "camel.jbang.excludes"; + + @Metadata(description = "Additional dependencies (Use commas to separate multiple dependencies).", + javaType = "String") + public static final String DEPENDENCIES = "camel.jbang.dependencies"; + + @Metadata(description = "Additional Maven repositories (Use commas to separate multiple repositories).", + javaType = "String", label = "maven") + public static final String REPOSITORIES = "camel.jbang.repositories"; + + @Metadata(description = "Version to use for jib-maven-plugin if exporting to camel-main and have Kubernetes enabled (jkube.xxx options)", + javaType = "String", defaultValue = "3.4.5", label = "kubernetes") + public static final String JIB_MAVEN_PLUGIN_VERSION = "camel.jbang.jib-maven-plugin-version"; + + @Metadata(description = "Version to use for jkube-maven-plugin if exporting to camel-main and have Kubernetes enabled (jkube.xxx options)", + javaType = "String", defaultValue = "1.18.1", label = "kubernetes") + public static final String JKUBE_MAVEN_PLUGIN_VERSION = "camel.jbang.jkube-maven-plugin-version"; + + @Metadata(description = "Stubs all the matching endpoint with the given component name or pattern. Multiple names can be separated by comma. (all = everything).", + javaType = "String") + public static final String STUB = "camel.jbang.stub"; + + @Metadata(description = "Source directory for dynamically loading Camel file(s) to run. When using this, then files cannot be specified at the same time.", + javaType = "String", label = "advanced") + public static final String SOURCE_DIR = "camel.jbang.sourceDir"; + + @Metadata(description = "Whether to ignore route loading and compilation errors (use this with care!)", + javaType = "boolean", label = "advanced") + public static final String IGNORE_LOADING_ERROR = "camel.jbang.ignoreLoadingError"; + + @Metadata(description = "Whether to use lazy bean initialization (can help with complex classloading issues)", + javaType = "boolean", label = "advanced") + public static final String LAZY_BEAN = "camel.jbang.lazyBean"; + + @Metadata(description = "Allow user to type in required parameters in prompt if not present in application", + javaType = "boolean", label = "advanced") + public static final String PROMPT = "camel.jbang.prompt"; + + @Metadata(description = "Work directory for compiler. Can be used to write compiled classes or other resources.", + javaType = "String", defaultValue = ".camel-jbang/compile", label = "advanced") + public static final String COMPILE_WORK_DIR = "camel.jbang.compileWorkDir"; + + @Deprecated + @Metadata(description = "Health check at /observe/health on local HTTP server (port 8080 by default)", + javaType = "boolean", defaultValue = ".camel-jbang/compile", deprecationNote = "Deprecated: use observe instead") + public static final String HEALTH = "camel.jbang.health"; + + @Deprecated + @Metadata(description = "Metrics (Micrometer and Prometheus) at /observe/metrics on local HTTP server (port 8080 by default) when running standalone Camel", + javaType = "boolean", defaultValue = ".camel-jbang/compile", deprecationNote = "Deprecated: use observe instead") + public static final String METRICS = "camel.jbang.metrics"; + + @Metadata(description = "Developer console at /q/dev on local HTTP server (port 8080 by default)", + javaType = "boolean") + public static final String CONSOLE = "camel.jbang.console"; + + @Metadata(description = "Verbose output of startup activity (dependency resolution and downloading", + javaType = "boolean") + public static final String VERBOSE = "camel.jbang.verbose"; + + @Metadata(description = "The version of Apache Camel to use", + javaType = "String") + public static final String CAMEL_VERSION = "camel.jbang.camel-version"; + + @Metadata(description = "Run Camel in export mode", + javaType = "boolean", label = "internal") + public static final String EXPORT = "camel.jbang.export"; + + @Metadata(description = "Run Camel in debugging mode", + javaType = "boolean", label = "internal") + public static final String DEBUG = "camel.jbang.debug"; + + @Metadata(description = "Enables Java Flight Recorder saving recording to disk on exit", + javaType = "boolean") + public static final String JFR = "camel.jbang.jfr"; + + @Metadata(description = "Java Flight Recorder profile to use (such as default or profile)", + javaType = "String", defaultValue = "default") + public static final String JFR_PROFILE = "camel.jbang.jfr-profile"; + + @Metadata(description = "Whether to allow automatic downloading JAR dependencies (over the internet)", + javaType = "boolean", defaultValue = "true") + public static final String DOWNLOAD = "camel.jbang.download"; + + @Metadata(description = "Whether to automatic package scan JARs for custom Spring or Quarkus beans making them available for Camel JBang", + javaType = "boolean", label = "advanced") + public static final String PACKAGE_SCAN_JARS = "camel.jbang.packageScanJars"; + + @Metadata(description = "Run in the background", + javaType = "boolean", label = "internal") + public static final String BACKGROUND = "camel.jbang.background"; + + @Metadata(description = "To wait for run in background to startup successfully, before returning", + javaType = "boolean", defaultValue = "true", label = "internal") + public static final String BACKGROUND_WAIT = "camel.jbang.backgroundWait"; + + @Metadata(description = "To enable JVM remote debugging on the given port.", + javaType = "int", defaultValue = "4004", label = "internal") + public static final String JVM_DEBUG = "camel.jbang.jvmDebug"; + + @Metadata(description = "To run in transform mode", + javaType = "boolean", label = "internal") + public static final String TRANSFORM = "camel.jbang.transform"; + + @Metadata(description = "To use a custom Camel version when running or export to Spring Boot", + javaType = "String", label = "spring-boot") + public static final String CAMEL_SPRING_BOOT_VERSION = "camel.jbang.camelSpringBootVersion"; + + private CamelJBangConstants() { + } + +} diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/RuntimeUtil.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/RuntimeUtil.java index 0d641e07970..864a1d9547f 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/RuntimeUtil.java +++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/RuntimeUtil.java @@ -187,7 +187,7 @@ public final class RuntimeUtil { } public static String getDependencies(Properties properties) { - String deps = properties != null ? properties.getProperty("camel.jbang.dependencies") : null; + String deps = properties != null ? properties.getProperty(CamelJBangConstants.DEPENDENCIES) : null; if (deps != null) { deps = deps.trim(); if (!deps.isEmpty() && deps.charAt(0) == ',') { diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/VersionHelper.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/VersionHelper.java index c5377952f86..cb8c6c78bf7 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/VersionHelper.java +++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/VersionHelper.java @@ -46,8 +46,8 @@ public final class VersionHelper { * @return the Spring Boot version string, or null if no version can be determined */ public static String getSpringBootVersion(Supplier<String> supplier) { - if (System.getProperty("camel.jbang.camelSpringBootVersion") != null) { - return System.getProperty("camel.jbang.camelSpringBootVersion"); + if (System.getProperty(CamelJBangConstants.CAMEL_SPRING_BOOT_VERSION) != null) { + return System.getProperty(CamelJBangConstants.CAMEL_SPRING_BOOT_VERSION); } else if (supplier != null) { return supplier.get(); }
