2020
2121import java .io .BufferedReader ;
2222import java .io .File ;
23- import java .io .FileInputStream ;
2423import java .io .FileNotFoundException ;
2524import java .io .FileOutputStream ;
2625import java .io .IOException ;
5756import java .util .regex .Matcher ;
5857import java .util .regex .Pattern ;
5958import java .util .regex .PatternSyntaxException ;
59+ import java .util .stream .Collectors ;
6060
6161import org .apache .http .HttpHeaders ;
6262import org .apache .http .HttpHost ;
@@ -221,14 +221,17 @@ protected static List<String> getExcludedPackages(
221221 * @return quoted option-argument
222222 */
223223 protected static String quotedArgument (String value ) {
224+ if (value == null ) {
225+ return null ;
226+ }
224227 String arg = value ;
225228
229+ List <String > list = Arrays .stream (arg .split ("\n " )).map (String ::trim ).collect (Collectors .toList ());
230+ arg = String .join ("" , list );
231+
226232 if (arg != null && !arg .isEmpty ()) {
227233 arg = arg .replace ("'" , "\\ '" );
228234 arg = "'" + arg + "'" ;
229-
230- // To prevent javadoc error
231- arg = arg .replace ("\n " , " " );
232235 }
233236
234237 return arg ;
@@ -253,7 +256,7 @@ protected static String quotedPathArgument(String value) {
253256
254257 for (int i = 0 ; i < split .length ; i ++) {
255258 if (i != split .length - 1 ) {
256- pathBuilder .append (split [i ]).append ("\\ '" );
259+ pathBuilder .append (split [i ]. trim () ).append ("\\ '" );
257260 } else {
258261 pathBuilder .append (split [i ]);
259262 }
@@ -291,7 +294,7 @@ protected static void copyJavadocResources(File outputDirectory, File javadocDir
291294 String current ;
292295 while (st .hasMoreTokens ()) {
293296 current = st .nextToken ();
294- excludes .add ("**/" + current + "/**" );
297+ excludes .add ("**/" + current . trim () + "/**" );
295298 }
296299 }
297300
@@ -422,9 +425,9 @@ protected static List<String> getFilesFromSource(
422425 if (sourceFileIncludes == null ) {
423426 sourceFileIncludes = Collections .singletonList ("**/*.java" );
424427 }
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 ]));
428431 }
429432 ds .setBasedir (sourceDirectory );
430433 ds .scan ();
@@ -753,7 +756,7 @@ protected static void invokeMaven(
753756 if (!projectFile .isFile ()) {
754757 throw new IllegalArgumentException (projectFile .getAbsolutePath () + " is not a file." );
755758 }
756- if (goals == null || goals .size () == 0 ) {
759+ if (goals == null || goals .isEmpty () ) {
757760 throw new IllegalArgumentException ("goals should be not empty." );
758761 }
759762 if (localRepositoryDir == null || !localRepositoryDir .isDirectory ()) {
@@ -889,7 +892,7 @@ protected static String[] splitPath(final String path) {
889892 subpaths .add (pathTokenizer .nextToken ());
890893 }
891894
892- return subpaths .toArray (new String [subpaths . size () ]);
895+ return subpaths .toArray (new String [0 ]);
893896 }
894897
895898 /**
@@ -932,7 +935,7 @@ private static List<String> getClassNamesFromJar(File jarFile) throws IOExceptio
932935
933936 List <String > classes = new ArrayList <>();
934937 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 () ))) {
936939 for (JarEntry jarEntry = jarStream .getNextJarEntry ();
937940 jarEntry != null ;
938941 jarEntry = jarStream .getNextJarEntry ()) {
@@ -1179,7 +1182,7 @@ public String nextToken() throws NoSuchElementException {
11791182 lookahead = nextToken ;
11801183 }
11811184 }
1182- return token ;
1185+ return token . trim () ;
11831186 }
11841187 }
11851188
@@ -1223,7 +1226,7 @@ static List<String> toList(String src, String elementPrefix, String elementSuffi
12231226 sb .append (elementSuffix );
12241227 }
12251228
1226- result .add (sb .toString ());
1229+ result .add (sb .toString (). trim () );
12271230 }
12281231
12291232 return result ;
@@ -1513,7 +1516,7 @@ private static CloseableHttpClient createHttpClient(Settings settings, URL url)
15131516 builder .setUserAgent ("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" );
15141517
15151518 // 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 , "*/*" )));
15171520
15181521 if (settings != null && settings .getActiveProxy () != null ) {
15191522 Proxy activeProxy = settings .getActiveProxy ();
0 commit comments