public static void main(String[] args) { try { JApiCli jApiCli = new JApiCli(); jApiCli.run(args); } catch (JApiCmpException e) { LOGGER.log(Level.FINE, CAUGHT_EXCEPTION + e.getLocalizedMessage(), e); if (e.getReason() != JApiCmpException.Reason.NormalTermination) { System.err.println("E: " + e.getMessage()); System.out.println(USE_HELP_OR_H_FOR_MORE_INFORMATION); System.exit(1); } } catch (Exception e) { LOGGER.log(Level.FINE, CAUGHT_EXCEPTION + e.getLocalizedMessage(), e); System.err.println(String.format("Execution of %s failed: %s", JApiCmp.class.getSimpleName(), e.getMessage())); e.printStackTrace(); System.exit(1); } } }
private <T> T checkNonNull(T in, String errorMessage) { if (in == null) { throw new JApiCmpException(JApiCmpException.Reason.CliError, errorMessage); } else { return in; } } }
private static void verifyExisting(JApiCmpArchive jApiCmpArchive) { if (!jApiCmpArchive.getFile().exists()) { throw JApiCmpException.cliError("File '%s' does not exist.", jApiCmpArchive.getFile().getAbsolutePath()); } }
errorOutput.generate(); } catch (JApiCmpException e) { if (e.getReason() == JApiCmpException.Reason.IncompatibleChange) { throw new MojoFailureException(e.getMessage()); } else { throw new MojoExecutionException("Error while checking for incompatible changes", e);
private String appendUserDefinedClassPathEntries(ClassPool classPool, List<String> classPathEntries) { StringBuilder classPathAsString = new StringBuilder(); for (String classPathEntry : classPathEntries) { try { classPool.appendClassPath(classPathEntry); if (!classPathAsString.toString().endsWith(File.pathSeparator)) { classPathAsString.append(File.pathSeparator); } classPathAsString.append(classPathEntry); } catch (NotFoundException e) { throw JApiCmpException.forClassLoading(e, classPathEntry, this); } } return classPathAsString.toString(); }
public void verify() { if (oldArchives.isEmpty()) { throw new JApiCmpException(JApiCmpException.Reason.CliError, "Required option -o, --old is missing."); throw new JApiCmpException(JApiCmpException.Reason.CliError, "Required option -n, --new is missing."); File stylesheetFile = new File(pathname); if (!stylesheetFile.exists()) { throw JApiCmpException.cliError("HTML stylesheet '%s' does not exist.", pathname); throw JApiCmpException.cliError("Define a HTML output file, if you want to apply a stylesheet."); } else { if (getOldClassPath().isPresent() || getNewClassPath().isPresent()) { throw JApiCmpException.cliError("Please provide both options: " + CliParser.OLD_CLASSPATH + " and " + CliParser.NEW_CLASSPATH); } else { setClassPathMode(JApiCli.ClassPathMode.ONE_COMMON_CLASSPATH);
} catch (NotFoundException e) { if (!options.getIgnoreMissingClasses().ignoreClass(e.getMessage())) { throw JApiCmpException.forClassLoading(e, name, this); } catch (NotFoundException e) { if (!options.getIgnoreMissingClasses().ignoreClass(e.getMessage())) { throw JApiCmpException.forClassLoading(e, name, this); } catch (NotFoundException e) { if (!options.getIgnoreMissingClasses().ignoreClass(e.getMessage())) { throw JApiCmpException.forClassLoading(e, name, this); throw new JApiCmpException(Reason.IllegalState, "Unknown archive type: " + archiveType); throw new JApiCmpException(Reason.IllegalState, "Unknown classpath mode: " + this.options.getClassPathMode());
public static JApiCmpException cliError(String format, Object... args) { return of(Reason.CliError, format, args); }
errorOutput.generate(); } catch (JApiCmpException e) { if (e.getReason() == JApiCmpException.Reason.IncompatibleChange) { throw new BuildException(e.getMessage());
private String appendUserDefinedClassPathEntries(ClassPool classPool, List<String> classPathEntries) { StringBuilder classPathAsString = new StringBuilder(); for (String classPathEntry : classPathEntries) { try { classPool.appendClassPath(classPathEntry); if (!classPathAsString.toString().endsWith(File.pathSeparator)) { classPathAsString.append(File.pathSeparator); } classPathAsString.append(classPathEntry); } catch (NotFoundException e) { throw JApiCmpException.forClassLoading(e, classPathEntry, this); } } return classPathAsString.toString(); }
public void verify() { if (oldArchives.isEmpty()) { throw new JApiCmpException(JApiCmpException.Reason.CliError, "Required option -o, --old is missing."); throw new JApiCmpException(JApiCmpException.Reason.CliError, "Required option -n, --new is missing."); File stylesheetFile = new File(pathname); if (!stylesheetFile.exists()) { throw JApiCmpException.cliError("HTML stylesheet '%s' does not exist.", pathname); throw JApiCmpException.cliError("Define a HTML output file, if you want to apply a stylesheet."); } else { if (getOldClassPath().isPresent() || getNewClassPath().isPresent()) { throw JApiCmpException.cliError("Please provide both options: " + CliParser.OLD_CLASSPATH + " and " + CliParser.NEW_CLASSPATH); } else { setClassPathMode(JApiCli.ClassPathMode.ONE_COMMON_CLASSPATH);
} catch (NotFoundException e) { if (!options.getIgnoreMissingClasses().ignoreClass(e.getMessage())) { throw JApiCmpException.forClassLoading(e, name, this); } catch (NotFoundException e) { if (!options.getIgnoreMissingClasses().ignoreClass(e.getMessage())) { throw JApiCmpException.forClassLoading(e, name, this); } catch (NotFoundException e) { if (!options.getIgnoreMissingClasses().ignoreClass(e.getMessage())) { throw JApiCmpException.forClassLoading(e, name, this); throw new JApiCmpException(Reason.IllegalState, "Unknown archive type: " + archiveType); throw new JApiCmpException(Reason.IllegalState, "Unknown classpath mode: " + this.options.getClassPathMode());
public static JApiCmpException cliError(String format, Object... args) { return of(Reason.CliError, format, args); }
public static void main(String[] args) { try { JApiCli jApiCli = new JApiCli(); jApiCli.run(args); } catch (JApiCmpException e) { LOGGER.log(Level.FINE, CAUGHT_EXCEPTION + e.getLocalizedMessage(), e); if (e.getReason() != JApiCmpException.Reason.NormalTermination) { System.err.println("E: " + e.getMessage()); System.out.println(USE_HELP_OR_H_FOR_MORE_INFORMATION); System.exit(1); } } catch (Exception e) { LOGGER.log(Level.FINE, CAUGHT_EXCEPTION + e.getLocalizedMessage(), e); System.err.println(String.format("Execution of %s failed: %s", JApiCmp.class.getSimpleName(), e.getMessage())); e.printStackTrace(); System.exit(1); } } }
private <T> T checkNonNull(T in, String errorMessage) { if (in == null) { throw new JApiCmpException(JApiCmpException.Reason.CliError, errorMessage); } else { return in; } } }
private static boolean isCtClassSerializable(JarArchiveComparatorOptions options, CtClass clazz, JarArchiveComparator jarArchiveComparator) { ClassPool pool = clazz.getClassPool(); try { return clazz.subtypeOf(pool.get("java.io.Serializable")); } catch (NotFoundException e) { if (options.getIgnoreMissingClasses().ignoreClass(e.getMessage())) { return false; } else { throw JApiCmpException.forClassLoading(e, clazz.getName(), jarArchiveComparator); } } }
private static void verifyCanRead(JApiCmpArchive jApiCmpArchive) { if (!jApiCmpArchive.getFile().canRead()) { throw JApiCmpException.cliError("Cannot read file '%s'.", jApiCmpArchive.getFile().getAbsolutePath()); } }
public static JApiCmpException of(Reason reason, String format, Object... args) { String msg = String.format(format, args); return new JApiCmpException(reason, msg); }
private static boolean isCtClassSerializable(JarArchiveComparatorOptions options, CtClass clazz, JarArchiveComparator jarArchiveComparator) { ClassPool pool = clazz.getClassPool(); try { return clazz.subtypeOf(pool.get("java.io.Serializable")); } catch (NotFoundException e) { if (options.getIgnoreMissingClasses().ignoreClass(e.getMessage())) { return false; } else { throw JApiCmpException.forClassLoading(e, clazz.getName(), jarArchiveComparator); } } }
private static void verifyCanRead(JApiCmpArchive jApiCmpArchive) { if (!jApiCmpArchive.getFile().canRead()) { throw JApiCmpException.cliError("Cannot read file '%s'.", jApiCmpArchive.getFile().getAbsolutePath()); } }