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

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-help-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new ea69b66  Replace plexus-utils StringUtils with JDK calls
ea69b66 is described below

commit ea69b66b5da3777dc6597418eae0f674184e5a54
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Sat Nov 14 13:29:43 2026 +0100

    Replace plexus-utils StringUtils with JDK calls
---
 .../apache/maven/plugins/help/DescribeMojo.java    | 11 +++++++----
 .../maven/plugins/help/EffectivePomMojo.java       |  5 ++---
 .../maven/plugins/help/EffectiveSettingsMojo.java  | 14 +++++++++-----
 .../apache/maven/plugins/help/EvaluateMojo.java    |  9 ++++++---
 .../org/apache/maven/plugins/help/SystemMojo.java  | 22 +++++++++++++---------
 5 files changed, 37 insertions(+), 24 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java 
b/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
index ce502da..d1e4ba6 100644
--- a/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
+++ b/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
@@ -59,7 +59,6 @@ import org.apache.maven.project.ProjectBuildingRequest;
 import org.apache.maven.reporting.MavenReport;
 import org.apache.maven.shared.utils.logging.MessageUtils;
 import org.apache.maven.tools.plugin.generator.HtmlToPlainTextConverter;
-import org.codehaus.plexus.util.StringUtils;
 import org.eclipse.aether.RepositorySystem;
 import org.eclipse.aether.artifact.Artifact;
 import org.eclipse.aether.artifact.DefaultArtifact;
@@ -283,15 +282,19 @@ public class DescribeMojo extends AbstractHelpMojo {
      * @throws MojoExecutionException if the plugin could not be verify
      * @throws MojoFailureException   if groupId or artifactId is empty
      */
+    private static boolean isNotEmpty(String str) {
+        return str != null && !str.isEmpty();
+    }
+
     private PluginDescriptor lookupPluginDescriptor(PluginInfo pi) throws 
MojoExecutionException, MojoFailureException {
         Plugin forLookup = null;
-        if (StringUtils.isNotEmpty(pi.getPrefix())) {
+        if (isNotEmpty(pi.getPrefix())) {
             try {
                 forLookup = 
mojoDescriptorCreator.findPluginForPrefix(pi.getPrefix(), session);
             } catch (NoPluginFoundForPrefixException e) {
                 throw new MojoExecutionException("Unable to find the plugin 
with prefix: " + pi.getPrefix(), e);
             }
-        } else if (StringUtils.isNotEmpty(pi.getGroupId()) && 
StringUtils.isNotEmpty(pi.getArtifactId())) {
+        } else if (isNotEmpty(pi.getGroupId()) && 
isNotEmpty(pi.getArtifactId())) {
             forLookup = new Plugin();
             forLookup.setGroupId(pi.getGroupId());
             forLookup.setArtifactId(pi.getArtifactId());
@@ -311,7 +314,7 @@ public class DescribeMojo extends AbstractHelpMojo {
             throw new MojoFailureException(msg);
         }
 
-        if (StringUtils.isNotEmpty(pi.getVersion())) {
+        if (isNotEmpty(pi.getVersion())) {
             forLookup.setVersion(pi.getVersion());
         } else {
             try {
diff --git a/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java 
b/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java
index ac3294a..14bea42 100644
--- a/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java
+++ b/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java
@@ -39,7 +39,6 @@ import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.ProjectBuilder;
 import org.apache.maven.shared.utils.logging.MessageUtils;
-import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
 import org.codehaus.plexus.util.xml.XMLWriter;
 import org.codehaus.plexus.util.xml.XmlWriterUtil;
@@ -109,7 +108,7 @@ public class EffectivePomMojo extends AbstractEffectiveMojo 
{
         StringWriter w = new StringWriter();
         String encoding = output != null ? 
project.getModel().getModelEncoding() : System.getProperty("file.encoding");
         XMLWriter writer = new PrettyPrintXMLWriter(
-                w, StringUtils.repeat(" ", 
XmlWriterUtil.DEFAULT_INDENTATION_SIZE), encoding, null);
+                w, String.join("", 
Collections.nCopies(XmlWriterUtil.DEFAULT_INDENTATION_SIZE, " ")), encoding, 
null);
 
         writeHeader(writer);
 
@@ -220,7 +219,7 @@ public class EffectivePomMojo extends AbstractEffectiveMojo 
{
 
             String s = source.getModelId(); // by default, display modelId
 
-            if (StringUtils.isBlank(s) || s.contains("[unknown-version]")) {
+            if (s == null || s.chars().allMatch(Character::isWhitespace) || 
s.contains("[unknown-version]")) {
                 // unless it is blank or does not provide version information
                 s = source.toString();
             }
diff --git 
a/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java 
b/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java
index 27a5dd0..7e8b94f 100644
--- a/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java
+++ b/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java
@@ -25,6 +25,7 @@ import java.io.StringWriter;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
 import java.util.stream.Collectors;
@@ -39,7 +40,6 @@ import org.apache.maven.settings.Server;
 import org.apache.maven.settings.Settings;
 import org.apache.maven.settings.SettingsUtils;
 import org.apache.maven.settings.io.xpp3.SettingsXpp3Writer;
-import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
 import org.codehaus.plexus.util.xml.XMLWriter;
 import org.codehaus.plexus.util.xml.XmlWriterUtil;
@@ -94,7 +94,7 @@ public class EffectiveSettingsMojo extends 
AbstractEffectiveMojo {
                 ? copySettings.getModelEncoding()
                 : System.getProperty("file.encoding");
         XMLWriter writer = new PrettyPrintXMLWriter(
-                w, StringUtils.repeat(" ", 
XmlWriterUtil.DEFAULT_INDENTATION_SIZE), encoding, null);
+                w, String.join("", 
Collections.nCopies(XmlWriterUtil.DEFAULT_INDENTATION_SIZE, " ")), encoding, 
null);
 
         writeHeader(writer);
 
@@ -127,7 +127,7 @@ public class EffectiveSettingsMojo extends 
AbstractEffectiveMojo {
     private static void hidePasswords(Settings aSettings) {
         List<Proxy> proxies = aSettings.getProxies();
         for (Proxy proxy : proxies) {
-            if (StringUtils.isNotEmpty(proxy.getPassword())) {
+            if (isNotEmpty(proxy.getPassword())) {
                 proxy.setPassword("***");
             }
         }
@@ -135,11 +135,11 @@ public class EffectiveSettingsMojo extends 
AbstractEffectiveMojo {
         List<Server> servers = aSettings.getServers();
         for (Server server : servers) {
             // Password
-            if (StringUtils.isNotEmpty(server.getPassword())) {
+            if (isNotEmpty(server.getPassword())) {
                 server.setPassword("***");
             }
             // Passphrase
-            if (StringUtils.isNotEmpty(server.getPassphrase())) {
+            if (isNotEmpty(server.getPassphrase())) {
                 server.setPassphrase("***");
             }
         }
@@ -252,4 +252,8 @@ public class EffectiveSettingsMojo extends 
AbstractEffectiveMojo {
 
         return userName;
     }
+
+    private static boolean isNotEmpty(String str) {
+        return str != null && !str.isEmpty();
+    }
 }
diff --git a/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java 
b/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java
index abb3bcf..2708832 100644
--- a/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java
+++ b/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java
@@ -57,7 +57,6 @@ import org.apache.maven.settings.Settings;
 import org.apache.maven.settings.io.xpp3.SettingsXpp3Writer;
 import 
org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
 import org.codehaus.plexus.components.interactivity.InputHandler;
-import org.codehaus.plexus.util.StringUtils;
 import org.eclipse.aether.RepositoryException;
 import org.eclipse.aether.RepositorySystem;
 import org.eclipse.aether.artifact.Artifact;
@@ -348,7 +347,7 @@ public class EvaluateMojo extends AbstractHelpMojo {
             if (!list.isEmpty()) {
                 Object elt = list.iterator().next();
 
-                String name = 
StringUtils.lowercaseFirstLetter(elt.getClass().getSimpleName());
+                String name = 
lowercaseFirstLetter(elt.getClass().getSimpleName());
                 currentXStream.alias(pluralize(name), list.getClass());
             } else {
                 // try to detect the alias from question
@@ -450,7 +449,7 @@ public class EvaluateMojo extends AbstractHelpMojo {
                     if (name.contains(packageFilter) && !name.contains("$") && 
!name.endsWith(".package-info")) {
                         try {
                             Class<?> clazz = Class.forName(name);
-                            String alias = 
StringUtils.lowercaseFirstLetter(clazz.getSimpleName());
+                            String alias = 
lowercaseFirstLetter(clazz.getSimpleName());
                             xstreamObject.alias(alias, clazz);
                             if (!clazz.equals(Model.class)) {
                                 xstreamObject.omitField(clazz, 
"modelEncoding"); // unnecessary field
@@ -517,6 +516,10 @@ public class EvaluateMojo extends AbstractHelpMojo {
         return getMavenProject(artifactString);
     }
 
+    private static String lowercaseFirstLetter(String data) {
+        return Character.toLowerCase(data.charAt(0)) + data.substring(1);
+    }
+
     /**
      * @param name not null
      * @return the plural of the name
diff --git a/src/main/java/org/apache/maven/plugins/help/SystemMojo.java 
b/src/main/java/org/apache/maven/plugins/help/SystemMojo.java
index d482145..226b724 100644
--- a/src/main/java/org/apache/maven/plugins/help/SystemMojo.java
+++ b/src/main/java/org/apache/maven/plugins/help/SystemMojo.java
@@ -21,12 +21,12 @@ package org.apache.maven.plugins.help;
 import javax.inject.Inject;
 
 import java.io.IOException;
+import java.util.Collections;
 import java.util.Properties;
 
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.project.ProjectBuilder;
-import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.cli.CommandLineUtils;
 import org.eclipse.aether.RepositorySystem;
 
@@ -57,16 +57,16 @@ public class SystemMojo extends AbstractHelpMojo {
         StringBuilder message = new StringBuilder();
 
         message.append(LS);
-        message.append(StringUtils.repeat("=", LINE_LENGTH)).append(LS);
-        message.append(StringUtils.repeat("=", REPEAT));
+        message.append(repeat("=", LINE_LENGTH)).append(LS);
+        message.append(repeat("=", REPEAT));
         message.append(" Platform Properties Details ");
-        message.append(StringUtils.repeat("=", REPEAT)).append(LS);
-        message.append(StringUtils.repeat("=", LINE_LENGTH)).append(LS);
+        message.append(repeat("=", REPEAT)).append(LS);
+        message.append(repeat("=", LINE_LENGTH)).append(LS);
         message.append(LS);
 
-        message.append(StringUtils.repeat("=", LINE_LENGTH)).append(LS);
+        message.append(repeat("=", LINE_LENGTH)).append(LS);
         message.append("System Properties").append(LS);
-        message.append(StringUtils.repeat("=", LINE_LENGTH)).append(LS);
+        message.append(repeat("=", LINE_LENGTH)).append(LS);
 
         Properties systemProperties = System.getProperties();
         for (String key : systemProperties.stringPropertyNames()) {
@@ -75,9 +75,9 @@ public class SystemMojo extends AbstractHelpMojo {
         }
 
         message.append(LS).append(LS);
-        message.append(StringUtils.repeat("=", LINE_LENGTH)).append(LS);
+        message.append(repeat("=", LINE_LENGTH)).append(LS);
         message.append("Environment Variables").append(LS);
-        message.append(StringUtils.repeat("=", LINE_LENGTH)).append(LS);
+        message.append(repeat("=", LINE_LENGTH)).append(LS);
         Properties envVars = CommandLineUtils.getSystemEnvVars();
         for (String key : envVars.stringPropertyNames()) {
             message.append(LS);
@@ -105,4 +105,8 @@ public class SystemMojo extends AbstractHelpMojo {
             getLog().info(message);
         }
     }
+
+    private static String repeat(String str, int count) {
+        return String.join("", Collections.nCopies(count, str));
+    }
 }

Reply via email to