diff --git a/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/GradleBuildServerBuildSupport.java b/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/GradleBuildServerBuildSupport.java index 69158d094..7de7bf0dd 100644 --- a/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/GradleBuildServerBuildSupport.java +++ b/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/GradleBuildServerBuildSupport.java @@ -8,7 +8,9 @@ import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.LinkedList; @@ -122,6 +124,20 @@ public boolean applies(IProject project) { return Utils.isGradleBuildServerProject(project); } + public void onWillUpdate(Collection projects, IProgressMonitor monitor) throws CoreException { + Set roots = new HashSet<>(); + for (IProject project : projects) { + IPath rootPath = ProjectUtils.findBelongedWorkspaceRoot(project.getLocation()); + if (rootPath != null) { + roots.add(rootPath); + } + } + for (IPath rootPath : roots) { + BuildServer buildServer = ImporterPlugin.getBuildServerConnection(rootPath); + buildServer.workspaceReload().join(); + } + } + @Override public void update(IProject project, boolean force, IProgressMonitor monitor) throws CoreException { if (!applies(project)) { @@ -136,8 +152,6 @@ public void update(IProject project, boolean force, IProgressMonitor monitor) th return; } BuildServer buildServer = ImporterPlugin.getBuildServerConnection(rootPath); - buildServer.workspaceReload().join(); - Map> buildTargetMap = Utils.getBuildTargetsMappedByProjectPath(buildServer); for (URI uri : buildTargetMap.keySet()) { IProject projectFromUri = ProjectUtils.getProjectFromUri(uri.toString());