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/03/31 13:45:27 UTC
[camel] branch camel-3.20.x updated: CAMEL-19226: camel-jbang - Add repos option to export
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-3.20.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.20.x by this push:
new 92c17c45692 CAMEL-19226: camel-jbang - Add repos option to export
92c17c45692 is described below
commit 92c17c456928eaea37ce028312544f34725f557a
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Mar 31 15:44:46 2023 +0200
CAMEL-19226: camel-jbang - Add repos option to export
---
.../camel/dsl/jbang/core/commands/Export.java | 1 +
.../dsl/jbang/core/commands/ExportBaseCommand.java | 27 ++++++++++++++--------
2 files changed, 19 insertions(+), 9 deletions(-)
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 02a27bf11b4..867a668bd3e 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
@@ -88,6 +88,7 @@ public class Export extends ExportBaseCommand {
protected Integer export(ExportBaseCommand cmd) throws Exception {
// copy properties from this to cmd
cmd.profile = this.profile;
+ cmd.repos = this.repos;
cmd.dependencies = this.dependencies;
cmd.runtime = this.runtime;
cmd.gav = this.gav;
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 0d30d416261..af59bc85a6b 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
@@ -24,14 +24,15 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
-import java.util.StringJoiner;
import java.util.TreeSet;
import java.util.function.Function;
import java.util.regex.Matcher;
@@ -68,6 +69,10 @@ abstract class ExportBaseCommand extends CamelCommand {
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;
+
@CommandLine.Option(names = {
"--dep", "--deps" }, description = "Add additional dependencies (Use commas to separate multiple dependencies).")
protected String dependencies;
@@ -546,12 +551,12 @@ abstract class ExportBaseCommand extends CamelCommand {
* @param camelVersion the camel version
* @return repositories or null if none are in use
*/
- protected static String getMavenRepos(File settings, Properties prop, String camelVersion) throws Exception {
- StringJoiner sj = new StringJoiner(",");
+ protected String getMavenRepos(File settings, Properties prop, String camelVersion) throws Exception {
+ Set<String> answer = new LinkedHashSet<>();
- String repos = prop.getProperty("camel.jbang.repos");
- if (repos != null) {
- sj.add(repos);
+ String propRepos = prop.getProperty("camel.jbang.repos");
+ if (propRepos != null) {
+ answer.add(propRepos);
}
if (camelVersion == null) {
@@ -559,7 +564,7 @@ abstract class ExportBaseCommand extends CamelCommand {
}
// include apache snapshot repo if we use SNAPSHOT version of Camel
if (camelVersion.endsWith("-SNAPSHOT")) {
- sj.add("https://repository.apache.org/content/groups/snapshots/");
+ answer.add("https://repository.apache.org/content/groups/snapshots/");
}
// there may be additional extra repositories
@@ -567,11 +572,15 @@ abstract class ExportBaseCommand extends CamelCommand {
for (String line : lines) {
if (line.startsWith("repository=")) {
String r = StringHelper.after(line, "repository=");
- sj.add(r);
+ answer.add(r);
}
}
- return sj.toString();
+ if (this.repos != null) {
+ Collections.addAll(answer, this.repos.split(","));
+ }
+
+ return String.join(",", answer);
}
protected static boolean hasModeline(File settings) {