This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch utils
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/utils by this push:
     new ad1bf16b13 wip
ad1bf16b13 is described below

commit ad1bf16b13b1fb1da559a64ad1550dc97385054a
Author: Elliotte Rusty Harold <elh...@ibiblio.org>
AuthorDate: Sat Jan 11 08:25:09 2025 -0500

    wip
---
 .../org/apache/maven/cling/invoker/BaseParser.java | 19 ++++++++--
 .../apache/maven/cling/invoker/InvokerUtils.java   | 44 +---------------------
 .../apache/maven/cling/invoker/LookupInvoker.java  | 22 ++++++++++-
 .../maven/cling/invoker/mvn/MavenInvoker.java      |  6 +--
 4 files changed, 40 insertions(+), 51 deletions(-)

diff --git 
a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/BaseParser.java 
b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/BaseParser.java
index 99c2595cf6..c24f18cbe9 100644
--- 
a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/BaseParser.java
+++ 
b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/BaseParser.java
@@ -38,6 +38,7 @@ import java.util.function.Function;
 import java.util.stream.Collectors;
 
 import org.apache.maven.api.Constants;
+import org.apache.maven.api.annotations.Nonnull;
 import org.apache.maven.api.annotations.Nullable;
 import org.apache.maven.api.cli.InvokerRequest;
 import org.apache.maven.api.cli.Options;
@@ -56,16 +57,15 @@ import static java.util.Objects.requireNonNull;
 import static org.apache.maven.cling.invoker.InvokerUtils.getCanonicalPath;
 import static org.apache.maven.cling.invoker.InvokerUtils.or;
 import static org.apache.maven.cling.invoker.InvokerUtils.prefix;
-import static 
org.apache.maven.cling.invoker.InvokerUtils.stripLeadingAndTrailingQuotes;
 import static org.apache.maven.cling.invoker.InvokerUtils.toMap;
 
 public abstract class BaseParser implements Parser {
 
     @Nullable
-    private static Path findRoot( Path topDirectory ) {
+    private static Path findRoot(Path topDirectory) {
         requireNonNull(topDirectory, "topDirectory");
         Path rootDirectory =
-                ServiceLoader.load( 
RootLocator.class).iterator().next().findRoot(topDirectory);
+                
ServiceLoader.load(RootLocator.class).iterator().next().findRoot(topDirectory);
         if (rootDirectory != null) {
             return getCanonicalPath(rootDirectory);
         }
@@ -197,6 +197,19 @@ public abstract class BaseParser implements Parser {
         }
     }
 
+    @Nonnull
+    private static String stripLeadingAndTrailingQuotes(String str) {
+        requireNonNull(str, "str");
+        final int length = str.length();
+        if (length > 1
+                && str.startsWith("\"")
+                && str.endsWith("\"")
+                && str.substring(1, length - 1).indexOf('"') == -1) {
+            str = str.substring(1, length - 1);
+        }
+        return str;
+    }
+
     protected Path getTopDirectory(LocalContext context) throws 
ParserException {
         // We need to locate the top level project which may be pointed at 
using
         // the -f/--file option.
diff --git 
a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/InvokerUtils.java 
b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/InvokerUtils.java
index 5cbb4c0e25..5fa72f4579 100644
--- 
a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/InvokerUtils.java
+++ 
b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/InvokerUtils.java
@@ -32,30 +32,16 @@ import org.apache.maven.execution.MavenExecutionRequest;
 import org.codehaus.plexus.interpolation.AbstractValueSource;
 import org.codehaus.plexus.interpolation.BasicInterpolator;
 import org.codehaus.plexus.interpolation.StringSearchInterpolator;
-import org.codehaus.plexus.logging.Logger;
 
 import static java.util.Objects.requireNonNull;
 
 /**
- * Various mostly internal utilities used in org.apache.maven.cling.invoker 
and its subpackages.
+ * Various internal utilities used in org.apache.maven.cling.invoker and its 
subpackages.
  * Not documented, tested, or intended for external uses.
  */
 public final class InvokerUtils {
     private InvokerUtils() {}
 
-    @Nonnull
-    public static String stripLeadingAndTrailingQuotes(String str) {
-        requireNonNull(str, "str");
-        final int length = str.length();
-        if (length > 1
-                && str.startsWith("\"")
-                && str.endsWith("\"")
-                && str.substring(1, length - 1).indexOf('"') == -1) {
-            str = str.substring(1, length - 1);
-        }
-        return str;
-    }
-
     @Nonnull
     public static Path getCanonicalPath(Path path) {
         requireNonNull(path, "path");
@@ -76,16 +62,6 @@ public final class InvokerUtils {
         return map;
     }
 
-    @Nonnull
-    public static Properties toProperties(Map<String, String> properties) {
-        requireNonNull(properties, "properties");
-        Properties map = new Properties();
-        for (String key : properties.keySet()) {
-            map.put(key, properties.get(key));
-        }
-        return map;
-    }
-
     @Nonnull
     public static BasicInterpolator createInterpolator(Collection<Map<String, 
String>> properties) {
         StringSearchInterpolator interpolator = new StringSearchInterpolator();
@@ -129,22 +105,4 @@ public final class InvokerUtils {
         };
     }
 
-    public static int 
toMavenExecutionRequestLoggingLevel(Slf4jConfiguration.Level level) {
-        requireNonNull(level, "level");
-        return switch (level) {
-            case DEBUG -> MavenExecutionRequest.LOGGING_LEVEL_DEBUG;
-            case INFO -> MavenExecutionRequest.LOGGING_LEVEL_INFO;
-            case ERROR -> MavenExecutionRequest.LOGGING_LEVEL_ERROR;
-        };
-    }
-
-    public static int toPlexusLoggingLevel(Slf4jConfiguration.Level level) {
-        requireNonNull(level, "level");
-        return switch (level) {
-            case DEBUG -> Logger.LEVEL_DEBUG;
-            case INFO -> Logger.LEVEL_INFO;
-            case ERROR -> Logger.LEVEL_ERROR;
-        };
-    }
-
 }
diff --git 
a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java
 
b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java
index f2bd6e0639..de988f62e3 100644
--- 
a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java
+++ 
b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java
@@ -35,6 +35,7 @@ import java.util.function.Function;
 
 import org.apache.maven.api.Constants;
 import org.apache.maven.api.ProtoSession;
+import org.apache.maven.api.annotations.Nonnull;
 import org.apache.maven.api.annotations.Nullable;
 import org.apache.maven.api.cli.Invoker;
 import org.apache.maven.api.cli.InvokerException;
@@ -87,8 +88,6 @@ import org.slf4j.LoggerFactory;
 import org.slf4j.spi.LocationAwareLogger;
 
 import static java.util.Objects.requireNonNull;
-import static 
org.apache.maven.cling.invoker.InvokerUtils.toMavenExecutionRequestLoggingLevel;
-import static org.apache.maven.cling.invoker.InvokerUtils.toProperties;
 
 /**
  * Lookup invoker implementation, that boots up DI container.
@@ -462,6 +461,15 @@ public abstract class LookupInvoker<C extends 
LookupContext> implements Invoker
         context.eventSpyDispatcher.init(() -> data);
     }
 
+    private static Properties toProperties(Map<String, String> properties) {
+        requireNonNull(properties, "properties");
+        Properties map = new Properties();
+        for (String key : properties.keySet()) {
+            map.put(key, properties.get(key));
+        }
+        return map;
+    }
+
     protected void postCommands(C context) throws Exception {
         InvokerRequest invokerRequest = context.invokerRequest;
         Logger logger = context.logger;
@@ -674,6 +682,16 @@ public abstract class LookupInvoker<C extends 
LookupContext> implements Invoker
                 .resolve("repository");
     }
 
+    @Nonnull
+    private static int 
toMavenExecutionRequestLoggingLevel(Slf4jConfiguration.Level level) {
+        requireNonNull(level, "level");
+        return switch (level) {
+            case DEBUG -> MavenExecutionRequest.LOGGING_LEVEL_DEBUG;
+            case INFO -> MavenExecutionRequest.LOGGING_LEVEL_INFO;
+            case ERROR -> MavenExecutionRequest.LOGGING_LEVEL_ERROR;
+        };
+    }
+
     protected void populateRequest(C context, Lookup lookup, 
MavenExecutionRequest request) throws Exception {
         populateRequestFromSettings(request, context.effectiveSettings);
 
diff --git 
a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvn/MavenInvoker.java
 
b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvn/MavenInvoker.java
index 0415ea4bbb..8165565912 100644
--- 
a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvn/MavenInvoker.java
+++ 
b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvn/MavenInvoker.java
@@ -91,10 +91,10 @@ public class MavenInvoker extends 
LookupInvoker<MavenContext> {
     }
 
     @Nonnull
-    private static Path findMandatoryRoot( Path topDirectory ) {
+    private static Path findMandatoryRoot(Path topDirectory) {
         requireNonNull(topDirectory, "topDirectory");
-        return InvokerUtils.getCanonicalPath( Optional.ofNullable(
-                        ServiceLoader.load( 
RootLocator.class).iterator().next().findMandatoryRoot(topDirectory))
+        return InvokerUtils.getCanonicalPath(Optional.ofNullable(
+                        
ServiceLoader.load(RootLocator.class).iterator().next().findMandatoryRoot(topDirectory))
                 .orElseThrow());
     }
 

Reply via email to