From 16c1c15d7afd2933563dc998ee6d2b262510ada3 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Mon, 12 Dec 2022 14:05:21 +0100 Subject: [PATCH] JPS: cancel currently running build on project closing GitOrigin-RevId: edce4b864acdb1e9129b26c68fa2fbce0b5b049f --- .../com/intellij/compiler/server/BuildManager.java | 14 +++++++++++--- .../messages/JavaCompilerBundle.properties | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) 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 6b3cee613e6f..1661a2743cae 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java @@ -118,7 +118,8 @@ import org.jetbrains.jps.model.java.compiler.JavaCompilers; import org.jvnet.winp.Priority; import org.jvnet.winp.WinProcess; -import javax.tools.*; +import javax.tools.JavaCompiler; +import javax.tools.ToolProvider; import java.awt.*; import java.io.File; import java.io.IOException; @@ -2078,15 +2079,22 @@ public final class BuildManager implements Disposable { @Override public void projectClosing(@NotNull Project project) { - String projectPath = Objects.requireNonNull(getProjectPath(project)); - ProgressManager.getInstance().run(new Task.Modal(project, JavaCompilerBundle.message("progress.title.cancelling.auto.make.builds"), false) { + final String projectPath = getProjectPath(project); + ProgressManager.getInstance().run(new Task.Modal(project, JavaCompilerBundle.message("progress.title.cancelling.running.builds"), false) { @Override public void run(@NotNull ProgressIndicator indicator) { + final TaskFuture currentBuild = myBuildsInProgress.get(projectPath); + if (currentBuild != null) { + currentBuild.cancel(false); + } myAutoMakeTask.cancelPendingExecution(); cancelPreloadedBuilds(projectPath); for (TaskFuture future : cancelAutoMakeTasks(project)) { future.waitFor(500, TimeUnit.MILLISECONDS); } + if (currentBuild != null) { + currentBuild.waitFor(15, TimeUnit.SECONDS); + } } }); } diff --git a/java/compiler/openapi/resources/messages/JavaCompilerBundle.properties b/java/compiler/openapi/resources/messages/JavaCompilerBundle.properties index 877fc8cf63b5..8efb74beeabd 100644 --- a/java/compiler/openapi/resources/messages/JavaCompilerBundle.properties +++ b/java/compiler/openapi/resources/messages/JavaCompilerBundle.properties @@ -213,7 +213,7 @@ button.add=&Add... eclipse.compiler.cross.platform.help.message=('/' recommended in paths for cross-platform configurations) eclipse.compiler.path.leave.empty.help.message=Path to ECJ batch compiler tool (leave empty to use bundled): eclipse.compiler.proceed.on.errors.option=Proceed on errors -progress.title.cancelling.auto.make.builds=Cancelling Auto-Make Builds +progress.title.cancelling.running.builds=Cancelling Running Builds abnormal.build.process.termination=Abnormal build process termination wsl.network.connection.failure=Cannot establish network connection from WSL to Windows host (could be blocked by firewall). More details: https://jb.gg/wsl-firewall unknown.build.process.error=unknown error