@@ -267,43 +267,6 @@ public void run() throws ExitException {
267267 checker .addSuppressAnnotation (a );
268268 }
269269
270- try {
271- final String [] bundledSignatures = cmd .getOptionValues (bundledsignaturesOpt .getLongOpt ());
272- if (bundledSignatures != null ) for (String bs : new LinkedHashSet <>(Arrays .asList (bundledSignatures ))) {
273- checker .addBundledSignatures (bs , null );
274- }
275-
276- final String [] signaturesFiles = cmd .getOptionValues (signaturesfileOpt .getLongOpt ());
277- if (signaturesFiles != null ) for (String sf : new LinkedHashSet <>(Arrays .asList (signaturesFiles ))) {
278- final File f = new File (sf ).getAbsoluteFile ();
279- checker .parseSignaturesFile (f );
280- }
281- final String [] signaturesWithSeverityWarn = cmd .getOptionValues (signatureswithseveritywarnOpt .getLongOpt ());
282- if (signaturesWithSeverityWarn != null ) {
283- checker .setSignaturesSeverity (Arrays .asList (signaturesWithSeverityWarn ), Checker .ViolationSeverity .WARNING );
284- }
285- final String [] signaturesWithSeveritySuppress = cmd .getOptionValues (signatureswithseveritysuppressOpt .getLongOpt ());
286- if (signaturesWithSeveritySuppress != null ) {
287- checker .setSignaturesSeverity (Arrays .asList (signaturesWithSeveritySuppress ), Checker .ViolationSeverity .SUPPRESS );
288- }
289- } catch (IOException ioe ) {
290- throw new ExitException (EXIT_ERR_OTHER , "IO problem while reading files with API signatures: " + ioe );
291- } catch (ParseException pe ) {
292- throw new ExitException (EXIT_ERR_OTHER , "Parsing signatures failed: " + pe .getMessage ());
293- }
294-
295- if (checker .hasNoSignatures ()) {
296- if (checker .noSignaturesFilesParsed ()) {
297- throw new ExitException (EXIT_ERR_CMDLINE , String .format (Locale .ENGLISH ,
298- "No API signatures given as parameters; use '--%s' and/or '--%s' to specify those!" ,
299- bundledsignaturesOpt .getLongOpt (), signaturesfileOpt .getLongOpt ()
300- ));
301- } else {
302- logger .info ("Skipping execution because no API signatures are available." );
303- return ;
304- }
305- }
306-
307270 logger .info ("Scanning for classes to check..." );
308271
309272 String [] includes = cmd .getOptionValues (includesOpt .getLongOpt ());
@@ -365,11 +328,47 @@ public void run() throws ExitException {
365328 "No classes found in jar/zip file %s (includes=%s, excludes=%s)." ,
366329 classesDirectory , Arrays .toString (includes ), Arrays .toString (excludes )));
367330 }
368-
369331 } else {
370332 throw new ExitException (EXIT_ERR_OTHER , "Classes directory parameter is neither a directory or a jar/zip file." );
371333 }
372-
334+
335+ try {
336+ final String [] bundledSignatures = cmd .getOptionValues (bundledsignaturesOpt .getLongOpt ());
337+ if (bundledSignatures != null ) for (String bs : new LinkedHashSet <>(Arrays .asList (bundledSignatures ))) {
338+ checker .addBundledSignatures (bs , null );
339+ }
340+
341+ final String [] signaturesFiles = cmd .getOptionValues (signaturesfileOpt .getLongOpt ());
342+ if (signaturesFiles != null ) for (String sf : new LinkedHashSet <>(Arrays .asList (signaturesFiles ))) {
343+ final File f = new File (sf ).getAbsoluteFile ();
344+ checker .parseSignaturesFile (f );
345+ }
346+ final String [] signaturesWithSeverityWarn = cmd .getOptionValues (signatureswithseveritywarnOpt .getLongOpt ());
347+ if (signaturesWithSeverityWarn != null ) {
348+ checker .setSignaturesSeverity (Arrays .asList (signaturesWithSeverityWarn ), Checker .ViolationSeverity .WARNING );
349+ }
350+ final String [] signaturesWithSeveritySuppress = cmd .getOptionValues (signatureswithseveritysuppressOpt .getLongOpt ());
351+ if (signaturesWithSeveritySuppress != null ) {
352+ checker .setSignaturesSeverity (Arrays .asList (signaturesWithSeveritySuppress ), Checker .ViolationSeverity .SUPPRESS );
353+ }
354+ } catch (IOException ioe ) {
355+ throw new ExitException (EXIT_ERR_OTHER , "IO problem while reading files with API signatures: " + ioe );
356+ } catch (ParseException pe ) {
357+ throw new ExitException (EXIT_ERR_OTHER , "Parsing signatures failed: " + pe .getMessage ());
358+ }
359+
360+ if (checker .hasNoSignatures ()) {
361+ if (checker .noSignaturesFilesParsed ()) {
362+ throw new ExitException (EXIT_ERR_CMDLINE , String .format (Locale .ENGLISH ,
363+ "No API signatures given as parameters; use '--%s' and/or '--%s' to specify those!" ,
364+ bundledsignaturesOpt .getLongOpt (), signaturesfileOpt .getLongOpt ()
365+ ));
366+ } else {
367+ logger .info ("Skipping execution because no API signatures are available." );
368+ return ;
369+ }
370+ }
371+
373372 try {
374373 checker .run ();
375374 } catch (ForbiddenApiException fae ) {
0 commit comments