public void eventReceived(AntEventSummary event) {
    latestEvent = event;

    final AntBuildEvent type = AntBuildEvent.valueOf(event.getType());

    switch (type) {
      case TARGET_STARTED:
        pushTarget(event.getTargetName(), true);
        break;
      case TARGET_FINISHED:
        popTarget();
        break;
      case TASK_STARTED:
        pushTarget(event.getTaskName(), false);
        break;
      case TASK_FINISHED:
        popTask();
        break;
    }

    parseMessage(event);
  }
  private void parseMessage(AntEventSummary event) {
    final String message = event.getMessage();

    if (message == null) {
      return;
    }

    final int priority = event.getPriority();

    if (priority == Project.MSG_ERR) {
      detailCallback.reportError(message, event.getFile(), event.getLineNumber(), event.getCode());
    } else if (priority == Project.MSG_WARN) {
      detailCallback.reportWarning(
          message, event.getFile(), event.getLineNumber(), event.getCode());
    }

    final Matcher matcher = JUNIT_SUMMARY.matcher(message);
    if (matcher.matches()) {
      matcher.start();

      junitTotal += Integer.parseInt(matcher.group(1));
      junitFailures += Integer.parseInt(matcher.group(2));
      junitErrors += Integer.parseInt(matcher.group(3));

      final StringBuffer buf =
          new StringBuffer(mostRecentTarget == null ? "junit" : mostRecentTarget);

      buf.append(" (");
      buf.append(junitTotal);
      buf.append("/");
      buf.append(junitFailures);
      buf.append("/");
      buf.append(junitErrors);
      buf.append(")");

      detailCallback.setDetail(buf.toString());
    }
  }