Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement onWillUpdate() in GradleBuildServerBuildSupport #1405

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -126,6 +128,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) {
BuildServerConnection connection = ImporterPlugin.getBuildServerConnection(rootPath);
connection.workspaceReload().join();
}
}

@Override
public void update(IProject project, boolean force, IProgressMonitor monitor) throws CoreException {
if (!applies(project)) {
Expand All @@ -139,10 +155,8 @@ public void update(IProject project, boolean force, IProgressMonitor monitor) th
JavaLanguageServerPlugin.logError("Cannot find workspace root for project: " + project.getName());
return;
}
BuildServerConnection buildServer = ImporterPlugin.getBuildServerConnection(rootPath);
buildServer.workspaceReload().join();

Map<URI, List<BuildTarget>> buildTargetMap = Utils.getBuildTargetsMappedByProjectPath(buildServer);
BuildServerConnection connection = ImporterPlugin.getBuildServerConnection(rootPath);
Map<URI, List<BuildTarget>> buildTargetMap = Utils.getBuildTargetsMappedByProjectPath(connection);
for (URI uri : buildTargetMap.keySet()) {
IProject projectFromUri = ProjectUtils.getProjectFromUri(uri.toString());
if (projectFromUri == null || !Utils.isGradleBuildServerProject(projectFromUri)) {
Expand Down
Loading