|
99 | 99 | import org.codehaus.plexus.util.DirectoryScanner;
|
100 | 100 | import org.codehaus.plexus.util.FileUtils;
|
101 | 101 | import org.codehaus.plexus.util.IOUtil;
|
102 |
| -import org.codehaus.plexus.util.StringUtils; |
103 | 102 | import org.codehaus.plexus.util.cli.CommandLineException;
|
104 | 103 | import org.codehaus.plexus.util.cli.CommandLineUtils;
|
105 | 104 | import org.codehaus.plexus.util.cli.Commandline;
|
@@ -200,24 +199,22 @@ protected static List<String> getExcludedPackages(
|
200 | 199 | }
|
201 | 200 |
|
202 | 201 | /**
|
203 |
| - * Convenience method to wrap an argument value in single quotes (i.e. <code>'</code>). Intended for values which |
204 |
| - * may contain whitespaces. <br> |
205 |
| - * To prevent javadoc error, the line separator (i.e. <code>\n</code>) are skipped. |
| 202 | + * Convenience method to wrap a command line option-argument in single quotes (i.e. <code>'</code>). Intended for values which |
| 203 | + * may contain whitespace. <br> |
| 204 | + * Line feeds (i.e. <code>\n</code>) are replaced with spaces, and single quotes are backslash escaped. |
206 | 205 | *
|
207 |
| - * @param value the argument value. |
208 |
| - * @return argument with quote |
| 206 | + * @param value the option-argument |
| 207 | + * @return quoted option-argument |
209 | 208 | */
|
210 | 209 | protected static String quotedArgument(String value) {
|
211 | 210 | String arg = value;
|
212 | 211 |
|
213 | 212 | if (arg != null && !arg.isEmpty()) {
|
214 |
| - if (arg.contains("'")) { |
215 |
| - arg = StringUtils.replace(arg, "'", "\\'"); |
216 |
| - } |
| 213 | + arg = arg.replace("'", "\\'"); |
217 | 214 | arg = "'" + arg + "'";
|
218 | 215 |
|
219 | 216 | // To prevent javadoc error
|
220 |
| - arg = StringUtils.replace(arg, "\n", " "); |
| 217 | + arg = arg.replace("\n", " "); |
221 | 218 | }
|
222 | 219 |
|
223 | 220 | return arg;
|
@@ -285,13 +282,13 @@ protected static void copyJavadocResources(File outputDirectory, File javadocDir
|
285 | 282 | }
|
286 | 283 |
|
287 | 284 | List<String> docFiles = FileUtils.getDirectoryNames(
|
288 |
| - javadocDir, "resources,**/doc-files", StringUtils.join(excludes.iterator(), ","), false, true); |
| 285 | + javadocDir, "resources,**/doc-files", String.join(",", excludes), false, true); |
289 | 286 | for (String docFile : docFiles) {
|
290 | 287 | File docFileOutput = new File(outputDirectory, docFile);
|
291 | 288 | FileUtils.mkdir(docFileOutput.getAbsolutePath());
|
292 | 289 | FileUtils.copyDirectoryStructure(new File(javadocDir, docFile), docFileOutput);
|
293 | 290 | List<String> files = FileUtils.getFileAndDirectoryNames(
|
294 |
| - docFileOutput, StringUtils.join(excludes.iterator(), ","), null, true, true, true, true); |
| 291 | + docFileOutput, String.join(",", excludes), null, true, true, true, true); |
295 | 292 | for (String filename : files) {
|
296 | 293 | File file = new File(filename);
|
297 | 294 |
|
@@ -457,18 +454,21 @@ protected static JavaVersion getJavadocVersion(File javadocExe)
|
457 | 454 | CommandLineUtils.StringStreamConsumer err = new JavadocOutputStreamConsumer();
|
458 | 455 |
|
459 | 456 | int exitCode = CommandLineUtils.executeCommandLine(cmd, out, err);
|
460 |
| - |
| 457 | + String errOutput = err.getOutput(); // non-null |
461 | 458 | if (exitCode != 0) {
|
462 |
| - StringBuilder msg = new StringBuilder("Exit code: " + exitCode + " - " + err.getOutput()); |
| 459 | + StringBuilder msg = new StringBuilder("Exit code: " + exitCode + " - " + errOutput); |
463 | 460 | msg.append('\n');
|
464 | 461 | msg.append("Command line was:").append(CommandLineUtils.toString(cmd.getCommandline()));
|
465 | 462 | throw new CommandLineException(msg.toString());
|
466 | 463 | }
|
467 | 464 |
|
468 |
| - if (StringUtils.isNotEmpty(err.getOutput())) { |
469 |
| - return JavaVersion.parse(extractJavadocVersion(err.getOutput())); |
470 |
| - } else if (StringUtils.isNotEmpty(out.getOutput())) { |
471 |
| - return JavaVersion.parse(extractJavadocVersion(out.getOutput())); |
| 465 | + if (!errOutput.isEmpty()) { |
| 466 | + return JavaVersion.parse(extractJavadocVersion(errOutput)); |
| 467 | + } else { |
| 468 | + String outOutput = out.getOutput(); // non-null |
| 469 | + if (!outOutput.isEmpty()) { |
| 470 | + return JavaVersion.parse(extractJavadocVersion(outOutput)); |
| 471 | + } |
472 | 472 | }
|
473 | 473 |
|
474 | 474 | throw new IllegalArgumentException("No output found from the command line 'javadoc -J-version'");
|
@@ -881,7 +881,7 @@ protected static String unifyPathSeparator(final String path) {
|
881 | 881 | return null;
|
882 | 882 | }
|
883 | 883 |
|
884 |
| - return StringUtils.join(splitPath(path), File.pathSeparator); |
| 884 | + return String.join(File.pathSeparator, splitPath(path)); |
885 | 885 | }
|
886 | 886 |
|
887 | 887 | // ----------------------------------------------------------------------
|
@@ -1494,14 +1494,19 @@ private static CloseableHttpClient createHttpClient(Settings settings, URL url)
|
1494 | 1494 | ProxyInfo proxyInfo = new ProxyInfo();
|
1495 | 1495 | proxyInfo.setNonProxyHosts(activeProxy.getNonProxyHosts());
|
1496 | 1496 |
|
1497 |
| - if (StringUtils.isNotEmpty(activeProxy.getHost()) |
| 1497 | + String activeProxyHost = activeProxy.getHost(); |
| 1498 | + if (activeProxyHost != null |
| 1499 | + && !activeProxyHost.isEmpty() |
1498 | 1500 | && (url == null || !ProxyUtils.validateNonProxyHosts(proxyInfo, url.getHost()))) {
|
1499 | 1501 | HttpHost proxy = new HttpHost(activeProxy.getHost(), activeProxy.getPort());
|
1500 | 1502 | builder.setProxy(proxy);
|
1501 | 1503 |
|
1502 |
| - if (StringUtils.isNotEmpty(activeProxy.getUsername()) && activeProxy.getPassword() != null) { |
| 1504 | + String activeProxyUsername = activeProxy.getUsername(); |
| 1505 | + if (activeProxyUsername != null |
| 1506 | + && !activeProxyUsername.isEmpty() |
| 1507 | + && activeProxy.getPassword() != null) { |
1503 | 1508 | Credentials credentials =
|
1504 |
| - new UsernamePasswordCredentials(activeProxy.getUsername(), activeProxy.getPassword()); |
| 1509 | + new UsernamePasswordCredentials(activeProxyUsername, activeProxy.getPassword()); |
1505 | 1510 |
|
1506 | 1511 | CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
|
1507 | 1512 | credentialsProvider.setCredentials(AuthScope.ANY, credentials);
|
|
0 commit comments