You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2023/07/01 12:06:53 UTC
[maven-javadoc-plugin] 01/01: [MJAVADOC-755] Use java.lang.String instead of StringUtils
This is an automated email from the ASF dual-hosted git repository.
elharo pushed a commit to branch files
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git
commit 42a2ab5b29536c7b254ef880107094579fa57b83
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Sat Jul 1 08:05:59 2023 -0400
[MJAVADOC-755] Use java.lang.String instead of StringUtils
---
.../apache/maven/plugins/javadoc/JavadocUtil.java | 37 +++++++++++++---------
1 file changed, 22 insertions(+), 15 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
index ccb13c8e..6514dcdc 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
@@ -99,7 +99,6 @@ import org.codehaus.plexus.languages.java.version.JavaVersion;
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.cli.Commandline;
@@ -212,12 +211,12 @@ public class JavadocUtil {
if (arg != null && !arg.isEmpty()) {
if (arg.contains("'")) {
- arg = StringUtils.replace(arg, "'", "\\'");
+ arg = arg.replace("'", "\\'");
}
arg = "'" + arg + "'";
// To prevent javadoc error
- arg = StringUtils.replace(arg, "\n", " ");
+ arg = arg.replace("\n", " ");
}
return arg;
@@ -285,13 +284,13 @@ public class JavadocUtil {
}
List<String> docFiles = FileUtils.getDirectoryNames(
- javadocDir, "resources,**/doc-files", StringUtils.join(excludes.iterator(), ","), false, true);
+ javadocDir, "resources,**/doc-files", String.join(",", excludes), false, true);
for (String docFile : docFiles) {
File docFileOutput = new File(outputDirectory, docFile);
FileUtils.mkdir(docFileOutput.getAbsolutePath());
FileUtils.copyDirectoryStructure(new File(javadocDir, docFile), docFileOutput);
List<String> files = FileUtils.getFileAndDirectoryNames(
- docFileOutput, StringUtils.join(excludes.iterator(), ","), null, true, true, true, true);
+ docFileOutput, String.join(",", excludes), null, true, true, true, true);
for (String filename : files) {
File file = new File(filename);
@@ -457,18 +456,21 @@ public class JavadocUtil {
CommandLineUtils.StringStreamConsumer err = new JavadocOutputStreamConsumer();
int exitCode = CommandLineUtils.executeCommandLine(cmd, out, err);
-
+ String errOutput = err.getOutput(); // non-null
if (exitCode != 0) {
- StringBuilder msg = new StringBuilder("Exit code: " + exitCode + " - " + err.getOutput());
+ StringBuilder msg = new StringBuilder("Exit code: " + exitCode + " - " + errOutput);
msg.append('\n');
msg.append("Command line was:").append(CommandLineUtils.toString(cmd.getCommandline()));
throw new CommandLineException(msg.toString());
}
- if (StringUtils.isNotEmpty(err.getOutput())) {
- return JavaVersion.parse(extractJavadocVersion(err.getOutput()));
- } else if (StringUtils.isNotEmpty(out.getOutput())) {
- return JavaVersion.parse(extractJavadocVersion(out.getOutput()));
+ if (!errOutput.isEmpty()) {
+ return JavaVersion.parse(extractJavadocVersion(errOutput));
+ } else {
+ String outOutput = out.getOutput(); // non-null
+ if (!outOutput.isEmpty()) {
+ return JavaVersion.parse(extractJavadocVersion(outOutput));
+ }
}
throw new IllegalArgumentException("No output found from the command line 'javadoc -J-version'");
@@ -881,7 +883,7 @@ public class JavadocUtil {
return null;
}
- return StringUtils.join(splitPath(path), File.pathSeparator);
+ return String.join(File.pathSeparator, splitPath(path));
}
// ----------------------------------------------------------------------
@@ -1494,14 +1496,19 @@ public class JavadocUtil {
ProxyInfo proxyInfo = new ProxyInfo();
proxyInfo.setNonProxyHosts(activeProxy.getNonProxyHosts());
- if (StringUtils.isNotEmpty(activeProxy.getHost())
+ String activeProxyHost = activeProxy.getHost();
+ if (activeProxyHost != null
+ && !activeProxyHost.isEmpty()
&& (url == null || !ProxyUtils.validateNonProxyHosts(proxyInfo, url.getHost()))) {
HttpHost proxy = new HttpHost(activeProxy.getHost(), activeProxy.getPort());
builder.setProxy(proxy);
- if (StringUtils.isNotEmpty(activeProxy.getUsername()) && activeProxy.getPassword() != null) {
+ String activeProxyUsername = activeProxy.getUsername();
+ if (activeProxyUsername != null
+ && !activeProxyUsername.isEmpty()
+ && activeProxy.getPassword() != null) {
Credentials credentials =
- new UsernamePasswordCredentials(activeProxy.getUsername(), activeProxy.getPassword());
+ new UsernamePasswordCredentials(activeProxyUsername, activeProxy.getPassword());
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, credentials);