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 2023/01/09 08:39:28 UTC
[camel] branch main updated: camel-jbang - Fixed CS
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 0503a85cd57 camel-jbang - Fixed CS
0503a85cd57 is described below
commit 0503a85cd575de8930a654913bbd777cd2710314
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Jan 9 09:39:13 2023 +0100
camel-jbang - Fixed CS
---
.../apache/camel/dsl/jbang/core/commands/Run.java | 62 +++++++++++-----------
1 file changed, 31 insertions(+), 31 deletions(-)
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 f2a25c191f9..db7478b98ab 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
@@ -273,34 +273,12 @@ class Run extends CamelCommand {
removeDir(work);
work.mkdirs();
- Properties profileProperties = null;
- File profilePropertiesFile = new File(getProfile() + ".properties");
- if (profilePropertiesFile.exists()) {
- profileProperties = loadProfileProperties(profilePropertiesFile);
- // logging level/color may be configured in the properties file
- loggingLevel = profileProperties.getProperty("loggingLevel", loggingLevel);
- loggingColor
- = "true".equals(profileProperties.getProperty("loggingColor", loggingColor ? "true" : "false"));
- loggingJson
- = "true".equals(profileProperties.getProperty("loggingJson", loggingJson ? "true" : "false"));
- if (propertiesFiles == null) {
- propertiesFiles = "file:" + getProfile() + ".properties";
- } else {
- propertiesFiles = propertiesFiles + ",file:" + profilePropertiesFile.getName();
- }
- repos = profileProperties.getProperty("camel.jbang.repos", repos);
- mavenSettings = profileProperties.getProperty("camel.jbang.maven-settings", mavenSettings);
- mavenSettingsSecurity = profileProperties.getProperty("camel.jbang.maven-settings-security", mavenSettingsSecurity);
- openapi = profileProperties.getProperty("camel.jbang.open-api", openapi);
- download = "true".equals(profileProperties.getProperty("camel.jbang.download", download ? "true" : "false"));
- background = "true".equals(profileProperties.getProperty("camel.jbang.background", background ? "true" : "false"));
- camelVersion = profileProperties.getProperty("camel.jbang.camel-version", camelVersion);
- }
-
- // generate open-api early
+ Properties profileProperties = loadProfileProperties();
+ configureLogging();
if (openapi != null) {
generateOpenApi();
}
+
// route code as option
if (code != null) {
// store code in temporary file
@@ -332,11 +310,7 @@ class Run extends CamelCommand {
files = files.stream().distinct().collect(Collectors.toList());
}
- // configure logging first
- configureLogging();
-
final KameletMain main = createMainInstance();
-
main.setRepos(repos);
main.setDownload(download);
main.setFresh(fresh);
@@ -495,7 +469,6 @@ class Run extends CamelCommand {
sjReload.add(file.substring(5));
}
}
-
writeSetting(main, profileProperties, "camel.main.name", name);
if (js.length() > 0) {
@@ -572,7 +545,6 @@ class Run extends CamelCommand {
}
// okay we have validated all input and are ready to run
-
if (camelVersion != null) {
// run in another JVM with different camel version (foreground or background)
return runCamelVersion(main);
@@ -585,6 +557,34 @@ class Run extends CamelCommand {
}
}
+ private Properties loadProfileProperties() throws Exception {
+ Properties answer = null;
+
+ File profilePropertiesFile = new File(getProfile() + ".properties");
+ if (profilePropertiesFile.exists()) {
+ answer = loadProfileProperties(profilePropertiesFile);
+ // logging level/color may be configured in the properties file
+ loggingLevel = answer.getProperty("loggingLevel", loggingLevel);
+ loggingColor
+ = "true".equals(answer.getProperty("loggingColor", loggingColor ? "true" : "false"));
+ loggingJson
+ = "true".equals(answer.getProperty("loggingJson", loggingJson ? "true" : "false"));
+ if (propertiesFiles == null) {
+ propertiesFiles = "file:" + getProfile() + ".properties";
+ } else {
+ propertiesFiles = propertiesFiles + ",file:" + profilePropertiesFile.getName();
+ }
+ repos = answer.getProperty("camel.jbang.repos", repos);
+ mavenSettings = answer.getProperty("camel.jbang.maven-settings", mavenSettings);
+ mavenSettingsSecurity = answer.getProperty("camel.jbang.maven-settings-security", mavenSettingsSecurity);
+ openapi = answer.getProperty("camel.jbang.open-api", openapi);
+ download = "true".equals(answer.getProperty("camel.jbang.download", download ? "true" : "false"));
+ background = "true".equals(answer.getProperty("camel.jbang.background", background ? "true" : "false"));
+ camelVersion = answer.getProperty("camel.jbang.camel-version", camelVersion);
+ }
+ return answer;
+ }
+
protected int runCamelVersion(KameletMain main) throws Exception {
String cmd = ProcessHandle.current().info().commandLine().orElse(null);
if (cmd != null) {