diff --git a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java index a882fcd4df6d..1e0ee428259b 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java @@ -20,8 +20,14 @@ import com.intellij.execution.process.*; import com.intellij.execution.runners.ExecutionEnvironment; import com.intellij.ide.DataManager; import com.intellij.ide.PowerSaveMode; +import com.intellij.ide.actions.RevealFileAction; import com.intellij.ide.file.BatchFileChangeListener; +import com.intellij.notification.Notification; +import com.intellij.notification.NotificationType; +import com.intellij.notification.Notifications; import com.intellij.openapi.Disposable; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.application.*; import com.intellij.openapi.compiler.*; @@ -1176,6 +1182,7 @@ public final class BuildManager implements Disposable { yourKitProfilerService.copyYKLibraries(workDirectory); String yjpagent = workDirectory.resolve(yourKitProfilerService.getYKAgentFullName()).toAbsolutePath().toString(); cmdLine.addParameter("-agentpath:" + yjpagent + "=disablealloc,delay=10000,sessionname=ExternalBuild"); + showSnapshotNotificationAfterFinish(project); } catch (IOException e) { LOG.warn(e); @@ -1341,6 +1348,27 @@ public final class BuildManager implements Disposable { return processHandler; } + private static void showSnapshotNotificationAfterFinish(@NotNull Project project) { + MessageBusConnection busConnection = project.getMessageBus().connect(Disposer.newDisposable()); + busConnection.subscribe(BuildManagerListener.TOPIC, new BuildManagerListener() { + @Override + public void buildFinished(@NotNull Project project, @NotNull UUID sessionId, boolean isAutomake) { + busConnection.disconnect(); + File snapshotDir = new File(SystemProperties.getUserHome(), "snapshots"); + Notification notification = + new Notification("build.profiler", JavaCompilerBundle.message("notification.title.cpu.snapshot.build.has.been.captured"), "", NotificationType.INFORMATION); + notification.addAction(new AnAction(JavaCompilerBundle.message("action.show.snapshot.location.text")) { + @Override + public void actionPerformed(@NotNull AnActionEvent e) { + RevealFileAction.openDirectory(snapshotDir); + notification.expire(); + } + }); + Notifications.Bus.notify(notification, project); + } + }); + } + private static boolean shouldIncludeEclipseCompiler(CompilerConfiguration config) { if (config instanceof CompilerConfigurationImpl) { final BackendCompiler javaCompiler = ((CompilerConfigurationImpl)config).getDefaultCompiler(); diff --git a/java/compiler/openapi/resources/messages/JavaCompilerBundle.properties b/java/compiler/openapi/resources/messages/JavaCompilerBundle.properties index 247c1ba46ebc..f43a8b6f6bbb 100644 --- a/java/compiler/openapi/resources/messages/JavaCompilerBundle.properties +++ b/java/compiler/openapi/resources/messages/JavaCompilerBundle.properties @@ -314,3 +314,5 @@ element.with.manifest.label.manifest.file=Manifest &File: notification.group.title.jps.cannot.start.compiler=Cannot start compilation notification.action.jps.open.configuration.dialog=Configure... notification.title.jps.cannot.start.compiler=Cannot start compiler +notification.title.cpu.snapshot.build.has.been.captured=CPU snapshot of build has been captured +action.show.snapshot.location.text=Show Snapshot Location