long (final CompileContextImpl compileContext, final CompileStatusNotification callback, final ExitStatus _status) { long endCompilationStamp = System.currentTimeMillis(); compileContext.getBuildSession().setEndCompilationStamp(_status, endCompilationStamp); final long duration = endCompilationStamp - compileContext.getStartCompilationStamp(); if (!myProject.isDisposed()) { if (_status != ExitStatus.UP_TO_DATE && _status != ExitStatus.CANCELLED) { // refresh on output roots is required in order for the order enumerator to see all roots via VFS // have to refresh in case of errors too, because run configuration may be set to ignore errors Collection<String> affectedRoots = ReadAction.compute(() -> { Module[] affectedModules = compileContext.getCompileScope().getAffectedModules(); return ContainerUtil.newHashSet(CompilerPaths.getOutputPaths(affectedModules)); }); if (!affectedRoots.isEmpty()) { ProgressIndicator indicator = compileContext.getProgressIndicator(); indicator.setText(JavaCompilerBundle.message("synchronizing.output.directories")); CompilerUtil.refreshOutputRoots(affectedRoots); indicator.setText(""); } } } SwingUtilities.invokeLater(() -> { int errorCount = 0; int warningCount = 0; try { errorCount = compileContext.getMessageCount(CompilerMessageCategory.ERROR); warningCount = compileContext.getMessageCount(CompilerMessageCategory.WARNING); } finally { if (callback != null) { callback.finished(_status == ExitStatus.CANCELLED, errorCount, warningCount, compileContext); } } if (!myProject.isDisposed()) { final String statusMessage = createStatusMessage(_status, warningCount, errorCount, duration); final MessageType messageType = errorCount > 0 ? MessageType.ERROR : warningCount > 0 ? MessageType.WARNING : MessageType.INFO; if (duration > ONE_MINUTE_MS && CompilerWorkspaceConfiguration.getInstance(myProject).DISPLAY_NOTIFICATION_POPUP) { String toolWindowId = useBuildToolWindow() ? BuildContentManager.TOOL_WINDOW_ID : ToolWindowId.MESSAGES_WINDOW; ToolWindowManager.getInstance(myProject).notifyByBalloon(toolWindowId, messageType, statusMessage); } String wrappedMessage = _status == ExitStatus.UP_TO_DATE ? statusMessage : HtmlChunk.link("#", statusMessage).toString(); Notification notification = CompilerManager.NOTIFICATION_GROUP.createNotification(wrappedMessage, messageType.toNotificationType()) .setListener(new BuildToolWindowActivationListener(compileContext)) .setImportant(false); compileContext.getBuildSession().registerCloseAction(notification::expire); notification.notify(myProject); if (_status != ExitStatus.UP_TO_DATE && compileContext.getMessageCount(null) > 0) { final String msg = DateFormatUtil.formatDateTime(new Date()) + " - " + statusMessage; compileContext.addMessage(CompilerMessageCategory.INFORMATION, msg, null, -1, -1); } } }); return duration; }