Skip to content

Commit

Permalink
feat: Implement onWillUpdate() in GradleBuildServerBuildSupport
Browse files Browse the repository at this point in the history
Signed-off-by: Sheng Chen <[email protected]>
  • Loading branch information
jdneo committed Sep 6, 2023
1 parent a129d2c commit 650fb8e
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -122,6 +124,20 @@ public boolean applies(IProject project) {
return Utils.isGradleBuildServerProject(project);
}

public void onWillUpdate(Collection<IProject> projects, IProgressMonitor monitor) throws CoreException {
Set<IPath> 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)) {
Expand All @@ -136,8 +152,6 @@ public void update(IProject project, boolean force, IProgressMonitor monitor) th
return;
}
BuildServer buildServer = ImporterPlugin.getBuildServerConnection(rootPath);
buildServer.workspaceReload().join();

Map<URI, List<BuildTarget>> buildTargetMap = Utils.getBuildTargetsMappedByProjectPath(buildServer);
for (URI uri : buildTargetMap.keySet()) {
IProject projectFromUri = ProjectUtils.getProjectFromUri(uri.toString());
Expand Down

0 comments on commit 650fb8e

Please sign in to comment.