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/07/11 07:26:49 UTC
[camel] branch main updated: CAMEL-19592: camel-jbang - Export to camel-main to include embedded HTTP server
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 97fdb5acfa7 CAMEL-19592: camel-jbang - Export to camel-main to include embedded HTTP server
97fdb5acfa7 is described below
commit 97fdb5acfa729d9ebca9e09b0c69b13221a65959
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jul 11 09:24:23 2023 +0200
CAMEL-19592: camel-jbang - Export to camel-main to include embedded HTTP server
---
.../dsl/jbang/core/commands/ExportBaseCommand.java | 12 ++++++++++++
.../dsl/jbang/core/commands/ExportCamelMain.java | 19 ++++++++++++++++---
.../src/main/resources/templates/main-pom.tmpl | 6 +++++-
3 files changed, 33 insertions(+), 4 deletions(-)
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 2ff5ce828c8..0c661ca02b8 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
@@ -630,6 +630,18 @@ abstract class ExportBaseCommand extends CamelCommand {
return false;
}
+ protected static int httpServerPort(File settings) {
+ try {
+ List<String> lines = Files.readAllLines(settings.toPath());
+ String port = lines.stream().filter(l -> l.startsWith("camel.jbang.platform-http.port="))
+ .map(s -> StringHelper.after(s, "=")).findFirst().orElse("-1");
+ return Integer.parseInt(port);
+ } catch (Exception e) {
+ // ignore
+ }
+ return -1;
+ }
+
protected static void safeCopy(File source, File target, boolean override) throws Exception {
if (!source.exists()) {
return;
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 bbd3d9f6fea..96e9a6cb658 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
@@ -103,6 +103,17 @@ class ExportCamelMain extends Export {
if (!hasModeline(settings)) {
prop.remove("camel.main.modeline");
}
+ // are we using http then enable embedded HTTP server (if not explicit configured already)
+ int port = httpServerPort(settings);
+ if (port != -1 && !prop.containsKey("camel.server.enabled")) {
+ prop.put("camel.server.enabled", "true");
+ if (port != 8080 && !prop.containsKey("camel.server.port")) {
+ prop.put("camel.server.port", port);
+ }
+ if (!prop.containsKey("camel.server.health-check-enabled")) {
+ prop.put("camel.server.health-check-enabled", "true");
+ }
+ }
return prop;
});
// create main class
@@ -242,10 +253,12 @@ class ExportCamelMain extends Export {
answer.removeIf(s -> s.contains("camel-main"));
answer.removeIf(s -> s.contains("camel-health"));
- // if platform-http is included then we need vertx as implementation
- if (answer.stream().anyMatch(s -> s.contains("camel-platform-http") && !s.contains("camel-platform-http-vertx"))) {
+ // if platform-http is included then we need to switch to use camel-platform-http-main as implementation
+ if (answer.stream().anyMatch(s -> s.contains("camel-platform-http") && !s.contains("camel-platform-http-main"))) {
+ answer.removeIf(s -> s.contains("org.apache.camel:camel-platform-http:"));
+ answer.removeIf(s -> s.contains("org.apache.camel:camel-platform-http-vertx:"));
// version does not matter
- answer.add("mvn:org.apache.camel:camel-platform-http-vertx:1.0-SNAPSHOT");
+ answer.add("mvn:org.apache.camel:camel-platform-http-main:1.0-SNAPSHOT");
}
return answer;
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/main-pom.tmpl b/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/main-pom.tmpl
index 36f82169413..6ae7762e9cb 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/main-pom.tmpl
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/main-pom.tmpl
@@ -98,7 +98,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
- <version>3.5.0</version>
+ <version>3.6.0</version>
<configuration>
<descriptors>
<descriptor>src/main/resources/assembly/runner.xml</descriptor>
@@ -107,7 +107,11 @@
<manifest>
<mainClass>{{ .MainClassname }}</mainClass>
</manifest>
+ <manifestEntries>
+ <Multi-Release>true</Multi-Release>
+ </manifestEntries>
</archive>
+ <appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>