예제 #1
0
  @Override
  public void execute() throws BuildException {
    if (null == _from) throw new IllegalStateException("Missing 'from'.");
    if (null == _to) throw new IllegalStateException("Missing 'to'.");

    try {
      final FailureHandler failureHandler = new FailureHandler();
      new ApiDiff(failureHandler, _ignoreSettings, _from, _to, _platform.defaultConfig()).run();
      if (failureHandler.failures() > 0) {
        throw new BuildException(
            "API surfaces do not match. " + format(failureHandler) + " been reported.",
            getLocation());
      }
    } catch (IOException e) {
      throw new BuildException(e, getLocation());
    }
  }
예제 #2
0
 private String format(final FailureHandler failureHandler) {
   final int failures = failureHandler.failures();
   return failures == 1 ? "1 failure has" : failures + " failures have";
 }