|
20 | 20 |
|
21 | 21 | import java.io.BufferedReader; |
22 | 22 | import java.io.File; |
23 | | -import java.io.FileInputStream; |
24 | 23 | import java.io.FileNotFoundException; |
25 | 24 | import java.io.FileOutputStream; |
26 | 25 | import java.io.IOException; |
@@ -222,9 +221,12 @@ protected static List<String> getExcludedPackages( |
222 | 221 | * @return quoted option-argument |
223 | 222 | */ |
224 | 223 | protected static String quotedArgument(String value) { |
| 224 | + if (value == null) { |
| 225 | + return null; |
| 226 | + } |
225 | 227 | String arg = value; |
226 | 228 |
|
227 | | - List<String> list = Arrays.stream(arg.split("\n")).map(String::trim).collect(Collectors.toList()); |
| 229 | + List<String> list = Arrays.stream(arg.split("\n")).map(String::trim).collect(Collectors.toList()); |
228 | 230 | arg = String.join("", list); |
229 | 231 |
|
230 | 232 | if (arg != null && !arg.isEmpty()) { |
@@ -254,7 +256,7 @@ protected static String quotedPathArgument(String value) { |
254 | 256 |
|
255 | 257 | for (int i = 0; i < split.length; i++) { |
256 | 258 | if (i != split.length - 1) { |
257 | | - pathBuilder.append(split[i]).append("\\'"); |
| 259 | + pathBuilder.append(split[i].trim()).append("\\'"); |
258 | 260 | } else { |
259 | 261 | pathBuilder.append(split[i]); |
260 | 262 | } |
@@ -292,7 +294,7 @@ protected static void copyJavadocResources(File outputDirectory, File javadocDir |
292 | 294 | String current; |
293 | 295 | while (st.hasMoreTokens()) { |
294 | 296 | current = st.nextToken(); |
295 | | - excludes.add("**/" + current + "/**"); |
| 297 | + excludes.add("**/" + current.trim() + "/**"); |
296 | 298 | } |
297 | 299 | } |
298 | 300 |
|
@@ -423,9 +425,9 @@ protected static List<String> getFilesFromSource( |
423 | 425 | if (sourceFileIncludes == null) { |
424 | 426 | sourceFileIncludes = Collections.singletonList("**/*.java"); |
425 | 427 | } |
426 | | - ds.setIncludes(sourceFileIncludes.toArray(new String[sourceFileIncludes.size()])); |
427 | | - if (sourceFileExcludes != null && sourceFileExcludes.size() > 0) { |
428 | | - ds.setExcludes(sourceFileExcludes.toArray(new String[sourceFileExcludes.size()])); |
| 428 | + ds.setIncludes(sourceFileIncludes.toArray(new String[0])); |
| 429 | + if (sourceFileExcludes != null && !sourceFileExcludes.isEmpty()) { |
| 430 | + ds.setExcludes(sourceFileExcludes.toArray(new String[0])); |
429 | 431 | } |
430 | 432 | ds.setBasedir(sourceDirectory); |
431 | 433 | ds.scan(); |
@@ -754,7 +756,7 @@ protected static void invokeMaven( |
754 | 756 | if (!projectFile.isFile()) { |
755 | 757 | throw new IllegalArgumentException(projectFile.getAbsolutePath() + " is not a file."); |
756 | 758 | } |
757 | | - if (goals == null || goals.size() == 0) { |
| 759 | + if (goals == null || goals.isEmpty()) { |
758 | 760 | throw new IllegalArgumentException("goals should be not empty."); |
759 | 761 | } |
760 | 762 | if (localRepositoryDir == null || !localRepositoryDir.isDirectory()) { |
@@ -890,7 +892,7 @@ protected static String[] splitPath(final String path) { |
890 | 892 | subpaths.add(pathTokenizer.nextToken()); |
891 | 893 | } |
892 | 894 |
|
893 | | - return subpaths.toArray(new String[subpaths.size()]); |
| 895 | + return subpaths.toArray(new String[0]); |
894 | 896 | } |
895 | 897 |
|
896 | 898 | /** |
@@ -933,7 +935,7 @@ private static List<String> getClassNamesFromJar(File jarFile) throws IOExceptio |
933 | 935 |
|
934 | 936 | List<String> classes = new ArrayList<>(); |
935 | 937 | Pattern pattern = Pattern.compile("(?i)^(META-INF/versions/(?<v>[0-9]+)/)?(?<n>.+)[.]class$"); |
936 | | - try (JarInputStream jarStream = new JarInputStream(new FileInputStream(jarFile))) { |
| 938 | + try (JarInputStream jarStream = new JarInputStream(Files.newInputStream(jarFile.toPath()))) { |
937 | 939 | for (JarEntry jarEntry = jarStream.getNextJarEntry(); |
938 | 940 | jarEntry != null; |
939 | 941 | jarEntry = jarStream.getNextJarEntry()) { |
@@ -1180,7 +1182,7 @@ public String nextToken() throws NoSuchElementException { |
1180 | 1182 | lookahead = nextToken; |
1181 | 1183 | } |
1182 | 1184 | } |
1183 | | - return token; |
| 1185 | + return token.trim(); |
1184 | 1186 | } |
1185 | 1187 | } |
1186 | 1188 |
|
@@ -1224,7 +1226,7 @@ static List<String> toList(String src, String elementPrefix, String elementSuffi |
1224 | 1226 | sb.append(elementSuffix); |
1225 | 1227 | } |
1226 | 1228 |
|
1227 | | - result.add(sb.toString()); |
| 1229 | + result.add(sb.toString().trim()); |
1228 | 1230 | } |
1229 | 1231 |
|
1230 | 1232 | return result; |
@@ -1514,7 +1516,7 @@ private static CloseableHttpClient createHttpClient(Settings settings, URL url) |
1514 | 1516 | builder.setUserAgent("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"); |
1515 | 1517 |
|
1516 | 1518 | // Some server reject requests that do not have an Accept header |
1517 | | - builder.setDefaultHeaders(Arrays.asList(new BasicHeader(HttpHeaders.ACCEPT, "*/*"))); |
| 1519 | + builder.setDefaultHeaders(Collections.singletonList(new BasicHeader(HttpHeaders.ACCEPT, "*/*"))); |
1518 | 1520 |
|
1519 | 1521 | if (settings != null && settings.getActiveProxy() != null) { |
1520 | 1522 | Proxy activeProxy = settings.getActiveProxy(); |
|
0 commit comments