mcarlett commented on code in PR #16874:
URL: https://github.com/apache/camel/pull/16874#discussion_r1927166674


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/update/UpdateRun.java:
##########
@@ -0,0 +1,207 @@
+/*
+ * 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.update;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+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.RuntimeCompletionCandidates;
+import org.apache.camel.dsl.jbang.core.common.RuntimeType;
+import org.apache.camel.dsl.jbang.core.common.RuntimeTypeConverter;
+import org.apache.camel.main.download.DownloadException;
+import org.apache.camel.main.download.MavenDependencyDownloader;
+import org.apache.camel.util.FileUtil;
+import picocli.CommandLine;
+
+/**
+ * Command to update a Camel project to a specified version. This command 
supports updating projects for different
+ * runtimes such as Camel Main, Spring Boot, and Quarkus. It uses Maven and 
OpenRewrite to apply the necessary updates.
+ */
[email protected](name = "run",
+                     description = "Update Camel project")
+public class UpdateRun extends CamelCommand {
+
+    @CommandLine.Parameters(description = "Update version", arity = "1")
+    private String version;
+
+    @CommandLine.Option(names = { "--openRewriteVersion" },
+                        defaultValue = "6.0.4")
+    String openRewriteVersion;
+
+    @CommandLine.Option(names = { "--camelArtifact" },
+                        defaultValue = "camel-upgrade-recipes")
+    String camelArtifactCoordinates;
+
+    @CommandLine.Option(names = { "--camelSpringBootArtifact" },
+                        defaultValue = "camel-spring-boot-upgrade-recipes")
+    String camelSpringBootArtifactCoordinates;
+
+    @CommandLine.Option(names = { "--camelArtifactVersion" },
+                        defaultValue = "4.8.0")
+    String camelArtifactVersion;
+
+    @CommandLine.Option(names = { "--debug" },
+                        defaultValue = "false")
+    boolean debug;
+
+    @CommandLine.Option(names = { "--quarkusMavenPluginVersion" },
+                        defaultValue = RuntimeType.QUARKUS_VERSION)
+    String quarkusMavenPluginVersion;
+
+    @CommandLine.Option(names = { "--quarkusMavenPluginGroupId" },
+                        defaultValue = "io.quarkus")
+    String quarkusMavenPluginGroupId;
+
+    @CommandLine.Option(names = { "--dryRun" },
+                        defaultValue = "false")
+    boolean dryRun;
+
+    @CommandLine.Option(names = { "--runtime" },
+                        completionCandidates = 
RuntimeCompletionCandidates.class,
+                        defaultValue = "camel-main",
+                        converter = RuntimeTypeConverter.class,
+                        description = "Runtime (${COMPLETION-CANDIDATES})")
+    RuntimeType runtime = RuntimeType.main;
+
+    @CommandLine.Option(names = { "--repos" },
+                        description = "Additional maven repositories for 
download on-demand (Use commas to separate multiple repositories)")
+    String repos;
+
+    @CommandLine.Option(names = { "--upgradeTimeout" },
+                        description = "Time to wait, in seconds, before 
shutting down the upgrade process",
+                        defaultValue = "240")
+    int upgradeTimeout;
+
+    public UpdateRun(CamelJBangMain main) {
+        super(main);
+    }
+
+    /**
+     * Executes the update command for a Camel project. This method determines 
the appropriate Maven command based on
+     * the runtime type (Camel Main, Spring Boot, or Quarkus) and executes it 
to update the project to the specified
+     * version.
+     *
+     * @return           the exit code of the update process (0 for success, 
-1 for failure)
+     * @throws Exception if an error occurs during the update process
+     */
+    @Override
+    public Integer doCall() throws Exception {
+        // Check if the current directory contains a Maven project (i.e., a 
pom.xml file)
+        if (Files.list(Path.of("."))
+                .filter(f -> f.getFileName().toString().equals("pom.xml"))
+                .count()
+            == 0) {

Review Comment:
   maybe you can refactor as Path.of(".")).noneMatch(f -> 
f.getFileName().toString().equals("pom.xml"))



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to