void buildFinished(boolean isProgressAborted, final long buildTimeInMilliseconds, @NotNull final AntBuildListener antBuildListener, OutputPacketProcessor dispatcher) {
    final boolean aborted = isProgressAborted || myIsAborted;

    dispatcher.processOutput(__ -> {
      if (!myProject.isDisposed()) { // if not disposed
        final String message = getFinishStatusText(aborted, buildTimeInMilliseconds);
        addCommand(new FinishBuildCommand(message));
        final StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject);
        if (statusBar != null) {
          statusBar.setInfo(message);
        }
        final AntBuildFileBase buildFile = myBuildFile;
        final boolean isBackground = buildFile != null && buildFile.isRunInBackground();
        final boolean shouldActivate = !isBackground || getErrorCount() > 0;
        UIUtil.invokeLaterIfNeeded(() -> {
          final Runnable finishRunnable = () -> {
            final int errorCount = getErrorCount();
            try {
              final AntBuildFileBase buildFile1 = myBuildFile;
              if (buildFile1 != null) {
                if (errorCount == 0 && buildFile1.isViewClosedWhenNoErrors()) {
                  close();
                }
                else if (errorCount > 0) {
                  myTreeView.scrollToFirstError();
                }
                else {
                  myTreeView.scrollToStatus();
                }
              }
              else {
                myTreeView.scrollToLastMessage();
              }
            }
            finally {
              VirtualFileManager.getInstance().asyncRefresh(
                () -> antBuildListener.buildFinished(aborted ? AntBuildListener.ABORTED : AntBuildListener.FINISHED_SUCCESSFULLY, errorCount));
            }
          };
          if (shouldActivate) {
            final ToolWindow toolWindow = !myProject.isDisposed() ? ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW) : null;
            if (toolWindow != null) { // can be null if project is closed
              toolWindow.activate(finishRunnable, false);
            }
            else {
              finishRunnable.run();
            }
          }
          else {
            finishRunnable.run();
          }
        });
      }
    });
    ApplicationManager.getApplication().invokeLater(() -> flushWhenSmart(false), ModalityState.any(), myProject.getDisposed());
  }
void buildFinished(boolean isProgressAborted, final long buildTimeInMilliseconds, @NotNull final AntBuildListener antBuildListener, OutputPacketProcessor dispatcher)