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