You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2024/03/12 14:29:06 UTC
(camel) branch main updated: Jbang profile (#13458)
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 026b5bc7ea0 Jbang profile (#13458)
026b5bc7ea0 is described below
commit 026b5bc7ea0103fe99144e4cf2a7aefbb61af96b
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Mar 12 15:28:56 2024 +0100
Jbang profile (#13458)
* CAMEL-17386: camel-main - Add profile option to choose dev/prod. Make camel-jbang use this new profile setting.
* CAMEL-17386: camel-main - Add profile option to choose dev/prod. Make camel-jbang use this new profile setting.
---
.../main/camel-main-configuration-metadata.json | 1 +
.../MainConfigurationPropertiesConfigurer.java | 6 ++
.../camel-main-configuration-metadata.json | 1 +
core/camel-main/src/main/docs/main.adoc | 3 +-
.../org/apache/camel/main/BaseMainSupport.java | 3 +
.../camel/main/MainConfigurationProperties.java | 34 +++++++++++
.../org/apache/camel/main/ProfileConfigurer.java | 66 ++++++++++++++++++++++
.../ROOT/pages/camel-4x-upgrade-guide-4_5.adoc | 8 +++
.../modules/ROOT/pages/camel-jbang.adoc | 41 ++++----------
.../dsl/jbang/core/commands/DependencyList.java | 4 +-
.../camel/dsl/jbang/core/commands/Export.java | 3 +-
.../dsl/jbang/core/commands/ExportBaseCommand.java | 9 ---
.../dsl/jbang/core/commands/ExportCamelMain.java | 2 +-
.../dsl/jbang/core/commands/ExportQuarkus.java | 2 +-
.../dsl/jbang/core/commands/ExportSpringBoot.java | 2 +-
.../apache/camel/dsl/jbang/core/commands/Run.java | 26 ++++-----
.../dsl/jbang/core/commands/SBOMGenerator.java | 7 +--
.../java/org/apache/camel/main/KameletMain.java | 34 +++++------
18 files changed, 167 insertions(+), 85 deletions(-)
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
index 2d3a5c16711..942ec07472f 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
@@ -84,6 +84,7 @@
{ "name": "camel.main.modeline", "description": "Whether camel-k style modeline is also enabled when not using camel-k. Enabling this allows to use a camel-k like experience by being able to configure various settings using modeline directly in your route source code.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.main.name", "description": "Sets the name of the CamelContext.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.main.producerTemplateCacheSize", "description": "Producer template endpoints cache size.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 1000 },
+ { "name": "camel.main.profile", "description": "Camel profile to use when running. The dev profile is for development, which enables a set of additional developer focus functionality, tracing, debugging, and gathering additional runtime statistics that are useful during development. However, those additional features has a slight overhead cost, and are not enabled for production profile. The default profile is prod.", "sourceType": "org.apache.camel.main.MainConfigurationProperties", [...]
{ "name": "camel.main.routeFilterExcludePattern", "description": "Used for filtering routes routes matching the given pattern, which follows the following rules: - Match by route id - Match by route input endpoint uri The matching is using exact match, by wildcard and regular expression as documented by PatternHelper#matchPattern(String,String) . For example to only include routes which starts with foo in their route id's, use: include=foo* And to exclude routes which starts from [...]
{ "name": "camel.main.routeFilterIncludePattern", "description": "Used for filtering routes matching the given pattern, which follows the following rules: - Match by route id - Match by route input endpoint uri The matching is using exact match, by wildcard and regular expression as documented by PatternHelper#matchPattern(String,String) . For example to only include routes which starts with foo in their route id's, use: include=foo* And to exclude routes which starts from JMS en [...]
{ "name": "camel.main.routesBuilderClasses", "description": "Sets classes names that implement RoutesBuilder .", "sourceType": "org.apache.camel.main.MainConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/MainConfigurationPropertiesConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/MainConfigurationPropertiesConfigurer.java
index c47d98469da..feaa3273ca3 100644
--- a/core/camel-main/src/generated/java/org/apache/camel/main/MainConfigurationPropertiesConfigurer.java
+++ b/core/camel-main/src/generated/java/org/apache/camel/main/MainConfigurationPropertiesConfigurer.java
@@ -151,6 +151,8 @@ public class MainConfigurationPropertiesConfigurer extends org.apache.camel.supp
case "Name": target.setName(property(camelContext, java.lang.String.class, value)); return true;
case "producertemplatecachesize":
case "ProducerTemplateCacheSize": target.setProducerTemplateCacheSize(property(camelContext, int.class, value)); return true;
+ case "profile":
+ case "Profile": target.setProfile(property(camelContext, java.lang.String.class, value)); return true;
case "routefilterexcludepattern":
case "RouteFilterExcludePattern": target.setRouteFilterExcludePattern(property(camelContext, java.lang.String.class, value)); return true;
case "routefilterincludepattern":
@@ -390,6 +392,8 @@ public class MainConfigurationPropertiesConfigurer extends org.apache.camel.supp
case "Name": return java.lang.String.class;
case "producertemplatecachesize":
case "ProducerTemplateCacheSize": return int.class;
+ case "profile":
+ case "Profile": return java.lang.String.class;
case "routefilterexcludepattern":
case "RouteFilterExcludePattern": return java.lang.String.class;
case "routefilterincludepattern":
@@ -630,6 +634,8 @@ public class MainConfigurationPropertiesConfigurer extends org.apache.camel.supp
case "Name": return target.getName();
case "producertemplatecachesize":
case "ProducerTemplateCacheSize": return target.getProducerTemplateCacheSize();
+ case "profile":
+ case "Profile": return target.getProfile();
case "routefilterexcludepattern":
case "RouteFilterExcludePattern": return target.getRouteFilterExcludePattern();
case "routefilterincludepattern":
diff --git a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
index 2d3a5c16711..942ec07472f 100644
--- a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
+++ b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
@@ -84,6 +84,7 @@
{ "name": "camel.main.modeline", "description": "Whether camel-k style modeline is also enabled when not using camel-k. Enabling this allows to use a camel-k like experience by being able to configure various settings using modeline directly in your route source code.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.main.name", "description": "Sets the name of the CamelContext.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.main.producerTemplateCacheSize", "description": "Producer template endpoints cache size.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 1000 },
+ { "name": "camel.main.profile", "description": "Camel profile to use when running. The dev profile is for development, which enables a set of additional developer focus functionality, tracing, debugging, and gathering additional runtime statistics that are useful during development. However, those additional features has a slight overhead cost, and are not enabled for production profile. The default profile is prod.", "sourceType": "org.apache.camel.main.MainConfigurationProperties", [...]
{ "name": "camel.main.routeFilterExcludePattern", "description": "Used for filtering routes routes matching the given pattern, which follows the following rules: - Match by route id - Match by route input endpoint uri The matching is using exact match, by wildcard and regular expression as documented by PatternHelper#matchPattern(String,String) . For example to only include routes which starts with foo in their route id's, use: include=foo* And to exclude routes which starts from [...]
{ "name": "camel.main.routeFilterIncludePattern", "description": "Used for filtering routes matching the given pattern, which follows the following rules: - Match by route id - Match by route input endpoint uri The matching is using exact match, by wildcard and regular expression as documented by PatternHelper#matchPattern(String,String) . For example to only include routes which starts with foo in their route id's, use: include=foo* And to exclude routes which starts from JMS en [...]
{ "name": "camel.main.routesBuilderClasses", "description": "Sets classes names that implement RoutesBuilder .", "sourceType": "org.apache.camel.main.MainConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
diff --git a/core/camel-main/src/main/docs/main.adoc b/core/camel-main/src/main/docs/main.adoc
index 7f70eafc246..2f1bf56bfa1 100644
--- a/core/camel-main/src/main/docs/main.adoc
+++ b/core/camel-main/src/main/docs/main.adoc
@@ -19,7 +19,7 @@ The following tables lists all the options:
// main options: START
=== Camel Main configurations
-The camel.main supports 116 options, which are listed below.
+The camel.main supports 117 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
@@ -89,6 +89,7 @@ The camel.main supports 116 options, which are listed below.
| *camel.main.modeline* | Whether camel-k style modeline is also enabled when not using camel-k. Enabling this allows to use a camel-k like experience by being able to configure various settings using modeline directly in your route source code. | false | boolean
| *camel.main.name* | Sets the name of the CamelContext. | | String
| *camel.main.producerTemplate{zwsp}CacheSize* | Producer template endpoints cache size. | 1000 | int
+| *camel.main.profile* | Camel profile to use when running. The dev profile is for development, which enables a set of additional developer focus functionality, tracing, debugging, and gathering additional runtime statistics that are useful during development. However, those additional features has a slight overhead cost, and are not enabled for production profile. The default profile is prod. | | String
| *camel.main.routeFilterExclude{zwsp}Pattern* | Used for filtering routes routes matching the given pattern, which follows the following rules: - Match by route id - Match by route input endpoint uri The matching is using exact match, by wildcard and regular expression as documented by PatternHelper#matchPattern(String,String) . For example to only include routes which starts with foo in their route id's, use: include=foo* And to exclude routes which starts from JMS endpoints, use: [...]
| *camel.main.routeFilterInclude{zwsp}Pattern* | Used for filtering routes matching the given pattern, which follows the following rules: - Match by route id - Match by route input endpoint uri The matching is using exact match, by wildcard and regular expression as documented by PatternHelper#matchPattern(String,String) . For example to only include routes which starts with foo in their route id's, use: include=foo* And to exclude routes which starts from JMS endpoints, use: exclude [...]
| *camel.main.routesBuilder{zwsp}Classes* | Sets classes names that implement RoutesBuilder . | | String
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
index 05ce66c0651..84c41283ba9 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
@@ -432,6 +432,9 @@ public abstract class BaseMainSupport extends BaseService {
// gathers the properties (key=value) that was auto-configured
final OrderedLocationProperties autoConfiguredProperties = new OrderedLocationProperties();
+ // configure the profile with pre-configured settings
+ ProfileConfigurer.configure(camelContext, mainConfigurationProperties.getProfile(), mainConfigurationProperties);
+
// need to eager allow to auto-configure properties component
if (mainConfigurationProperties.isAutoConfigurationEnabled()) {
autoConfigurationFailFast(camelContext, autoConfiguredProperties);
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java
index f64a9d5c78a..bd66aff9e1b 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java
@@ -26,6 +26,7 @@ import org.apache.camel.builder.LambdaRouteBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.spi.BootstrapCloseable;
import org.apache.camel.spi.Configurer;
+import org.apache.camel.spi.Metadata;
/**
* Global configuration for Camel Main to configure context name, stream caching and other global configurations.
@@ -34,6 +35,8 @@ import org.apache.camel.spi.Configurer;
public class MainConfigurationProperties extends DefaultConfigurationProperties<MainConfigurationProperties>
implements BootstrapCloseable {
+ @Metadata(enums = "dev,test,prod")
+ private String profile;
private boolean autoConfigurationEnabled = true;
private boolean autoConfigurationEnvironmentVariablesEnabled = true;
private boolean autoConfigurationSystemPropertiesEnabled = true;
@@ -382,6 +385,23 @@ public class MainConfigurationProperties extends DefaultConfigurationProperties<
// getter and setters
// --------------------------------------------------------------
+ public String getProfile() {
+ return profile;
+ }
+
+ /**
+ * Camel profile to use when running.
+ *
+ * The dev profile is for development, which enables a set of additional developer focus functionality, tracing,
+ * debugging, and gathering additional runtime statistics that are useful during development. However, those
+ * additional features has a slight overhead cost, and are not enabled for production profile.
+ *
+ * The default profile is prod.
+ */
+ public void setProfile(String profile) {
+ this.profile = profile;
+ }
+
public boolean isAutoConfigurationEnabled() {
return autoConfigurationEnabled;
}
@@ -636,6 +656,20 @@ public class MainConfigurationProperties extends DefaultConfigurationProperties<
// fluent builders
// --------------------------------------------------------------
+ /**
+ * Camel profile to use when running.
+ *
+ * The dev profile is for development, which enables a set of additional developer focus functionality, tracing,
+ * debugging, and gathering additional runtime statistics that are useful during development. However, those
+ * additional features has a slight overhead cost, and are not enabled for production profile.
+ *
+ * The default profile is prod.
+ */
+ public MainConfigurationProperties withProfile(String profile) {
+ this.profile = profile;
+ return this;
+ }
+
/**
* Whether auto configuration of components/dataformats/languages is enabled or not. When enabled the configuration
* parameters are loaded from the properties component and configured as defaults (similar to spring-boot
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/ProfileConfigurer.java b/core/camel-main/src/main/java/org/apache/camel/main/ProfileConfigurer.java
new file mode 100644
index 00000000000..83ce2603e0f
--- /dev/null
+++ b/core/camel-main/src/main/java/org/apache/camel/main/ProfileConfigurer.java
@@ -0,0 +1,66 @@
+/*
+ * 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.main;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ManagementStatisticsLevel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Configure Camel Main with the chosen profile.
+ *
+ * This is for Camel JBang and Standalone Camel, not Spring Boot or Quarkus; as they have their own profile concept.
+ */
+public class ProfileConfigurer {
+
+ protected static final Logger LOG = LoggerFactory.getLogger(ProfileConfigurer.class);
+
+ public static void configure(CamelContext camelContext, String profile, MainConfigurationProperties config)
+ throws Exception {
+ if (profile == null || "prod".equals(profile)) {
+ LOG.info("The application is starting with profile: production");
+ return; // no need to do special configuration
+ }
+ if ("test".equals(profile)) {
+ LOG.info("The application is starting with profile: test");
+ return; // current no special configuration
+ }
+ if ("dev".equals(profile)) {
+ LOG.info("The application is starting with profile: dev");
+ // always enable developer console as it is needed by camel-cli-connector
+ config.setDevConsoleEnabled(true);
+ // and enable a bunch of other stuff that gives more details for developers
+ config.setCamelEventsTimestampEnabled(true);
+ config.setLoadHealthChecks(true);
+ config.setSourceLocationEnabled(true);
+ config.setModeline(true);
+ config.setLoadStatisticsEnabled(true);
+ config.setMessageHistory(true);
+ config.setInflightRepositoryBrowseEnabled(true);
+ config.setEndpointRuntimeStatisticsEnabled(true);
+ config.setJmxManagementStatisticsLevel(ManagementStatisticsLevel.Extended);
+ config.setJmxUpdateRouteEnabled(true);
+ config.setShutdownLogInflightExchangesOnTimeout(false);
+ config.setShutdownTimeout(10);
+ config.setStartupRecorder("backlog");
+ // enable backlog tracing
+ config.tracerConfig().withEnabled(true);
+ }
+ }
+
+}
diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc
index a49dbb4928d..09e9b724834 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc
@@ -166,6 +166,14 @@ We also renamed the `route-curcuit-breaker` console to `circuit-breaker`.
=== camel-jbang
+The `--profile` option on `export` command has been removed.
+
+The `--profile` option on `run` command is now used by `camel-main` to choose profile mode when running Camel with JBang,
+or standalone with Camel Main. The default mode is `dev` for development which comes with some additional features enabled
+in Camel to gather more information that are relevant for development and the Camel JBang CLI.
+
+You can run with `--profile=prod` to turn off all of this, which makes Camel run more similar to a production situation.
+
The command `camel generate rest` have removed all the shorthand arguments `such as `-i -o` instead use the long names `--input --output`.
=== camel-jsonpath
diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
index d50e92f81a4..fb287b02931 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
@@ -528,44 +528,25 @@ curl -s -H "Accept: application/json" http://0.0.0.0:8080/q/dev/top/ | jq
=== Using profiles
-Camel JBang have the concept of profiles. A _profile_ is essentially a name (id) that refers
-to which configuration to automatic load with Camel JBang. The default profile is named `application`
-which is a (smart default) to let Camel JBang automatic load `application.properties` (if present).
+*Available from Camel 4.5*
-This means that creating profiles matching to a properties file with the same name.
+Camel JBang comes with three set of profiles
-For example having a profile named `local`, means that Camel JBang will load `local.properties` instead
-of `application.properties`.
+- `dev` - for development (default)
+- `test` - for testing (currently same as production)
+- `prod` - for production
-To use a profile, you specify as command line option `--profile` such as:
+The developer profile will pre-configure Camel JBang with a number of developer assisted features when
+running Camel. For example tracing messages during routing, additional metrics collected, and more.
+This is useful during development and also enhanced the Camel JBang CLI tool.
-[source,bash]
-----
-camel run hello.java --profile=local
-----
-
-You can only specify one profile name, i.e. `--profile=local,two` is not valid.
+However, you may want to run Camel JBang in a more production like situation, which you can do with:
-In the `properties` files you can configure all
-the configurations from xref:components:others:main.adoc[Camel Main].
-
-For example to turn off xref:stream-caching.adoc[Stream Caching] and enable log masking you can specify:
-
-[source,properties]
-----
-camel.main.streamCaching=false
-camel.main.logMask=true
-----
-
-And you can also configure Camel components such as camel-kafka to declare the URL to the brokers:
-
-[source,properties]
+[source,bash]
----
-camel.component.kafka.brokers=broker1:9092,broker2:9092,broker3:9092
+camel run hello.java --profile=prod
----
-NOTE: Keys starting with `camel.jbang` are reserved keys that are used by Camel JBang internally,
-and as well allow for pre-configuring arguments for Camel JBang commands.
=== Downloading JARs over the internet
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 a09b00ba1c9..e59ce15ed94 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
@@ -180,8 +180,8 @@ public class DependencyList extends Export {
}
protected Integer doExport() throws Exception {
- // read runtime and gav from profile if not configured
- File profile = new File(getProfile() + ".properties");
+ // read runtime and gav from properties if not configured
+ File profile = new File("application.properties");
if (profile.exists()) {
Properties prop = new CamelCaseOrderedProperties();
RuntimeUtil.loadProperties(prop, profile);
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 387eaea659e..ae6ef2ff17b 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
@@ -35,7 +35,7 @@ public class Export extends ExportBaseCommand {
@Override
protected Integer export() throws Exception {
- File profile = new File(getProfile() + ".properties");
+ File profile = new File("application.properties");
if (profile.exists()) {
Properties prop = new CamelCaseOrderedProperties();
RuntimeUtil.loadProperties(prop, profile);
@@ -97,7 +97,6 @@ public class Export extends ExportBaseCommand {
protected Integer export(ExportBaseCommand cmd) throws Exception {
// copy properties from this to cmd
cmd.files = this.files;
- cmd.profile = this.profile;
cmd.repos = this.repos;
cmd.dependencies = this.dependencies;
cmd.runtime = this.runtime;
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 2f5ac5f1472..de639ddf831 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
@@ -87,10 +87,6 @@ abstract class ExportBaseCommand extends CamelCommand {
protected List<String> files = new ArrayList<>();
- @CommandLine.Option(names = { "--profile" }, scope = CommandLine.ScopeType.INHERIT, defaultValue = "application",
- description = "Profile to use, which refers to loading properties file with the given profile name. By default application.properties is loaded.")
- protected String profile;
-
@CommandLine.Option(names = { "--repos" },
description = "Additional maven repositories (Use commas to separate multiple repositories)")
protected String repos;
@@ -238,10 +234,6 @@ abstract class ExportBaseCommand extends CamelCommand {
return export();
}
- public String getProfile() {
- return profile;
- }
-
protected static String mavenRepositoriesAsPomXml(String repos) {
StringBuilder sb = new StringBuilder();
int i = 1;
@@ -293,7 +285,6 @@ abstract class ExportBaseCommand extends CamelCommand {
protected Integer runSilently(boolean ignoreLoadingError) throws Exception {
Run run = new Run(getMain());
// need to declare the profile to use for run
- run.profile = profile;
run.localKameletDir = localKameletDir;
run.dependencies = dependencies;
run.files = files;
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java
index c12f14dbf51..1c6753fde44 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java
@@ -55,7 +55,7 @@ class ExportCamelMain extends Export {
System.err.println("--build-tool=gradle is not support yet for camel-main runtime.");
}
- File profile = new File(getProfile() + ".properties");
+ File profile = new File("application.properties");
// the settings file has information what to export
File settings = new File(CommandLineHelper.getWorkDir(), Run.RUN_SETTINGS_FILE);
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 6b27981458b..c736b920bfb 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
@@ -58,7 +58,7 @@ class ExportQuarkus extends Export {
return 1;
}
- File profile = new File(getProfile() + ".properties");
+ File profile = new File("application.properties");
// the settings file has information what to export
File settings = new File(CommandLineHelper.getWorkDir(), Run.RUN_SETTINGS_FILE);
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java
index ba3216744eb..694cbdfee6b 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java
@@ -59,7 +59,7 @@ class ExportSpringBoot extends Export {
return 1;
}
- File profile = new File(getProfile() + ".properties");
+ File profile = new File("application.properties");
// the settings file has information what to export
File settings = new File(CommandLineHelper.getWorkDir(), Run.RUN_SETTINGS_FILE);
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 ee4a23b1bfc..f380ede69ad 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
@@ -142,9 +142,9 @@ public class Run extends CamelCommand {
@Option(names = { "--kamelets-version" }, description = "Apache Camel Kamelets version")
String kameletsVersion;
- @Option(names = { "--profile" }, scope = CommandLine.ScopeType.INHERIT, defaultValue = "application",
- description = "Profile to use, which refers to loading properties file with the given profile name. By default application.properties is loaded.")
- String profile = "application";
+ @Option(names = { "--profile" }, scope = CommandLine.ScopeType.INHERIT, defaultValue = "dev",
+ description = "Profile to run (dev, test, or prod).")
+ String profile = "dev";
@Option(names = {
"--dep", "--deps" }, description = "Add additional dependencies (Use commas to separate multiple dependencies)")
@@ -288,10 +288,6 @@ public class Run extends CamelCommand {
super(main);
}
- public String getProfile() {
- return profile;
- }
-
@Override
public boolean disarrangeLogging() {
return false;
@@ -426,11 +422,11 @@ public class Run extends CamelCommand {
run = "debug";
}
System.err
- .println("Cannot " + run + " because " + getProfile()
- + ".properties file does not exist or camel.main.routesIncludePattern is not configured");
+ .println("Cannot " + run
+ + " because application.properties file does not exist or camel.main.routesIncludePattern is not configured");
return 1;
} else {
- // silent-run then auto-detect all files (except properties as they are loaded explicit or via profile)
+ // silent-run then auto-detect all files (except properties as they are loaded explicit)
String[] allFiles = new File(".").list((dir, name) -> !name.endsWith(".properties"));
if (allFiles != null) {
files.addAll(Arrays.asList(allFiles));
@@ -444,6 +440,7 @@ public class Run extends CamelCommand {
}
final KameletMain main = createMainInstance();
+ main.setProfile(profile);
main.setRepos(repos);
main.setDownload(download);
main.setFresh(fresh);
@@ -474,7 +471,6 @@ public class Run extends CamelCommand {
main.setStubPattern(stub);
}
- writeSetting(main, profileProperties, "camel.main.sourceLocationEnabled", "true");
if (dev) {
writeSetting(main, profileProperties, "camel.main.routesReloadEnabled", "true");
// allow quick shutdown during development
@@ -507,7 +503,9 @@ public class Run extends CamelCommand {
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, "camel.jbang.backlogTracing", "true");
+ if ("dev".equals(profile)) {
+ writeSetting(main, profileProperties, "camel.jbang.backlogTracing", "true");
+ }
// the runtime version of Camel is what is loaded via the catalog
writeSetting(main, profileProperties, "camel.jbang.camel-version", new DefaultCamelCatalog().getCatalogVersion());
@@ -848,9 +846,9 @@ public class Run extends CamelCommand {
File profilePropertiesFile;
if (sourceDir != null) {
- profilePropertiesFile = new File(sourceDir, getProfile() + ".properties");
+ profilePropertiesFile = new File(sourceDir, "application.properties");
} else {
- profilePropertiesFile = new File(getProfile() + ".properties");
+ profilePropertiesFile = new File("application.properties");
}
if (profilePropertiesFile.exists()) {
answer = loadProfileProperties(profilePropertiesFile);
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 a2ae9a6e42f..185ff0ac530 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
@@ -34,11 +34,8 @@ public class SBOMGenerator extends Export {
protected static final String EXPORT_DIR = CommandLineHelper.CAMEL_JBANG_WORK_DIR + "/export";
protected static final String CYCLONEDX_FORMAT = "cyclonedx";
-
protected static final String SPDX_FORMAT = "spdx";
-
protected static final String SBOM_JSON_FORMAT = "json";
-
protected static final String SBOM_XML_FORMAT = "xml";
@CommandLine.Option(names = { "--output-directory" }, description = "Directory where the SBOM will be saved",
@@ -147,8 +144,8 @@ public class SBOMGenerator extends Export {
}
protected Integer doExport() throws Exception {
- // read runtime and gav from profile if not configured
- File profile = new File(getProfile() + ".properties");
+ // read runtime and gav from properties if not configured
+ File profile = new File("application.properties");
if (profile.exists()) {
Properties prop = new CamelCaseOrderedProperties();
RuntimeUtil.loadProperties(prop, profile);
diff --git a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
index b22fe375f9e..349f8a2b6bc 100644
--- a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
+++ b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
@@ -29,7 +29,6 @@ import org.w3c.dom.Document;
import org.apache.camel.CamelContext;
import org.apache.camel.ExtendedCamelContext;
-import org.apache.camel.ManagementStatisticsLevel;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.dsl.support.SourceLoader;
@@ -104,6 +103,7 @@ public class KameletMain extends MainCommandLineSupport {
public static final String DEFAULT_KAMELETS_LOCATION = "classpath:/kamelets,github:apache:camel-kamelets/kamelets";
protected final MainRegistry registry = new MainRegistry();
+ private String profile = "dev";
private boolean download = true;
private String repos;
private boolean fresh;
@@ -182,6 +182,17 @@ public class KameletMain extends MainCommandLineSupport {
return registry.findByTypeWithName(type);
}
+ public String getProfile() {
+ return profile;
+ }
+
+ /**
+ * Camel profile to use (dev = development, prod = production). The default is dev.
+ */
+ public void setProfile(String profile) {
+ this.profile = profile;
+ }
+
public boolean isDownload() {
return download;
}
@@ -467,8 +478,9 @@ public class KameletMain extends MainCommandLineSupport {
}
}
}
-
}
+ configure().withProfile(profile);
+
// embed HTTP server if port is specified
Object port = getInitialProperties().get("camel.jbang.platform-http.port");
if (port != null) {
@@ -477,26 +489,11 @@ public class KameletMain extends MainCommandLineSupport {
}
boolean console = "true".equals(getInitialProperties().get("camel.jbang.console"));
if (console) {
+ configure().setDevConsoleEnabled(true);
configure().httpServer().withEnabled(true);
configure().httpServer().withInfoEnabled(true); // also enable info if console is enabled
configure().httpServer().withDevConsoleEnabled(true);
}
-
- // always enable developer console as it is needed by camel-cli-connector
- configure().withDevConsoleEnabled(true);
- // and enable a bunch of other stuff that gives more details for developers
- configure().withCamelEventsTimestampEnabled(true);
- configure().withLoadHealthChecks(true);
- configure().withModeline(true);
- configure().withLoadStatisticsEnabled(true);
- configure().withMessageHistory(true);
- configure().withInflightRepositoryBrowseEnabled(true);
- configure().withEndpointRuntimeStatisticsEnabled(true);
- configure().withJmxManagementStatisticsLevel(ManagementStatisticsLevel.Extended);
- configure().withShutdownLogInflightExchangesOnTimeout(false);
- configure().withShutdownTimeout(10);
- configure().withStartupRecorder("backlog");
-
boolean tracing = "true".equals(getInitialProperties().get("camel.jbang.backlogTracing"));
if (tracing) {
configure().tracerConfig().withEnabled(true);
@@ -769,7 +766,6 @@ public class KameletMain extends MainCommandLineSupport {
addInitialProperty("camel.component.rest-api.consumerComponentName", "platform-http");
addInitialProperty("camel.component.rest.consumerComponentName", "platform-http");
addInitialProperty("camel.component.rest.producerComponentName", "vertx-http");
- addInitialProperty("came.main.jmxUpdateRouteEnabled", "true");
}
protected String startupInfo() {