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/14 03:51:13 UTC
[camel] branch main updated: CAMEL-19128: camel-jbang - Set version command
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 d61b1bb4615 CAMEL-19128: camel-jbang - Set version command
d61b1bb4615 is described below
commit d61b1bb4615f662e9957c0f51d96f89da1cbb96e
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Mar 14 04:50:55 2023 +0100
CAMEL-19128: camel-jbang - Set version command
---
.../dsl/jbang/core/commands/CamelJBangMain.java | 2 +
.../jbang/core/commands/version/VersionSet.java | 71 ++++++++++++++++++++++
2 files changed, 73 insertions(+)
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
index 03eb94094e0..d0b9bfa7e9f 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
@@ -70,6 +70,7 @@ import org.apache.camel.dsl.jbang.core.commands.process.StopProcess;
import org.apache.camel.dsl.jbang.core.commands.version.VersionCommand;
import org.apache.camel.dsl.jbang.core.commands.version.VersionGet;
import org.apache.camel.dsl.jbang.core.commands.version.VersionList;
+import org.apache.camel.dsl.jbang.core.commands.version.VersionSet;
import org.apache.camel.dsl.jbang.core.common.CommandLineHelper;
import picocli.CommandLine;
import picocli.CommandLine.Command;
@@ -141,6 +142,7 @@ public class CamelJBangMain implements Callable<Integer> {
.addSubcommand("set", new CommandLine(new ConfigSet(main))))
.addSubcommand("version", new CommandLine(new VersionCommand(main))
.addSubcommand("get", new CommandLine(new VersionGet(main)))
+ .addSubcommand("set", new CommandLine(new VersionSet(main)))
.addSubcommand("list", new CommandLine(new VersionList(main))));
commandLine.getCommandSpec().versionProvider(() -> {
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/version/VersionSet.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/version/VersionSet.java
new file mode 100644
index 00000000000..6713e97c636
--- /dev/null
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/version/VersionSet.java
@@ -0,0 +1,71 @@
+/*
+ * 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.commands.version;
+
+import org.apache.camel.dsl.jbang.core.commands.CamelCommand;
+import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
+import org.apache.camel.dsl.jbang.core.common.CommandLineHelper;
+import org.apache.camel.dsl.jbang.core.common.RuntimeCompletionCandidates;
+import picocli.CommandLine;
+
+@CommandLine.Command(name = "set", description = "Set/change current Camel version")
+public class VersionSet extends CamelCommand {
+
+ @CommandLine.Parameters(description = "Camel version", arity = "0..1")
+ String version;
+
+ @CommandLine.Option(names = { "--runtime" }, completionCandidates = RuntimeCompletionCandidates.class,
+ description = "Runtime (spring-boot, quarkus, or camel-main)")
+ String runtime;
+
+ @CommandLine.Option(names = { "--repo", "--repos" }, description = "Maven repository for downloading the dependencies")
+ String repo;
+
+ @CommandLine.Option(names = { "--reset" }, description = "Reset by removing any custom version settings")
+ boolean reset;
+
+ public VersionSet(CamelJBangMain main) {
+ super(main);
+ }
+
+ @Override
+ public Integer call() throws Exception {
+ CommandLineHelper.createPropertyFile();
+
+ CommandLineHelper.loadProperties(properties -> {
+ if (reset) {
+ properties.remove("camel-version");
+ properties.remove("repos");
+ properties.remove("runtime");
+ } else {
+ if (version != null) {
+ properties.put("camel-version", version);
+ }
+ if (repo != null) {
+ properties.put("repos", repo);
+ }
+ if (runtime != null) {
+ properties.put("runtime", runtime);
+ }
+ }
+ CommandLineHelper.storeProperties(properties);
+ });
+
+ return 0;
+ }
+
+}