Skip to content

Commit 31d7521

Browse files
committed
Adopt the vscode-gradle changes
Signed-off-by: BoykoAlex <alex.boyko@broadcom.com>
1 parent 7ec1eed commit 31d7521

5 files changed

Lines changed: 5 additions & 43 deletions

File tree

‎eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/commands/ExecuteGradleTaskHandler.java‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ private void runBuild(Command cmd) throws ExecutionException {
9090
String buildGradlePath = (String) cmd.getArguments().get(0);
9191
GradleCommandLine commandLine = GradleCommandLine.parse((String) cmd.getArguments().get(1));
9292
String javaHome = cmd.getArguments().size() > 2 ? javaHome(cmd.getArguments().get(2)) : null;
93-
boolean refreshProject = cmd.getArguments().size() > 3 && refreshProject(cmd.getArguments().get(3));
9493

9594
IResource buildGradle = LSPEclipseUtils.findResourceFor(Paths.get(buildGradlePath).toUri());
9695
IProject project = buildGradle.getProject();
@@ -117,11 +116,9 @@ private void runBuild(Command cmd) throws ExecutionException {
117116
// Buildship's launch delegate only returns once the build has finished
118117
launchConfig.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
119118
} finally {
120-
if (refreshProject) {
121-
// The build writes files (e.g. the AOT metadata) the workspace does not know about yet.
122-
// Synchronize the project, which refreshes the workspace and updates the source folders.
123-
synchronize(project);
124-
}
119+
// The build writes files (e.g. the AOT metadata) the workspace does not know about yet.
120+
// Synchronize the project, which refreshes the workspace and updates the source folders.
121+
synchronize(project);
125122
if (!existed) {
126123
// Created for this build only, the build can use files that are gone after it (an init
127124
// script). Do not leave it around, but never delete a configuration of the user.
@@ -178,11 +175,6 @@ static GradleCommandLine parse(String command) {
178175
}
179176
}
180177

181-
// Same options as the `gradle.runBuild` command of vscode-gradle: { "refreshJavaProject": true }
182-
private static boolean refreshProject(Object options) {
183-
return options instanceof Map<?, ?> map && Boolean.TRUE.equals(map.get("refreshJavaProject"));
184-
}
185-
186178
private static String javaHome(Object env) {
187179
if (env instanceof Map<?, ?> map && map.get("JAVA_HOME") instanceof String javaHome && !javaHome.isBlank()) {
188180
return javaHome;

‎headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/VSCodeBuildCommandProvider.java‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
import java.nio.file.Paths;
1414
import java.util.List;
15-
import java.util.Map;
1615

1716
import org.eclipse.lsp4j.Command;
1817
import org.springframework.ide.vscode.commons.java.IJavaProject;
@@ -40,10 +39,7 @@ public Command executeGradleBuild(IJavaProject project, String command) {
4039
cmd.setArguments(List.of(
4140
Paths.get(project.getProjectBuild().getBuildFile()).toFile().toString(),
4241
command,
43-
BuildCommandProvider.buildEnv(project),
44-
// Have the client reload the project after the build. The builds are for generating sources and
45-
// resources, which only become source folders of the project at a project synchronization.
46-
Map.of("refreshJavaProject", true)
42+
BuildCommandProvider.buildEnv(project)
4743
));
4844
return cmd;
4945
}

‎headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/data/QueryMethodCodeActionProvider.java‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,8 @@
2727
import org.springframework.ide.vscode.boot.java.jdt.refactoring.JdtRefactorings;
2828
import org.springframework.ide.vscode.commons.Version;
2929
import org.springframework.ide.vscode.commons.java.IJavaProject;
30-
import org.springframework.ide.vscode.commons.java.IProjectBuild;
3130
import org.springframework.ide.vscode.commons.java.SpringProjectUtil;
3231
import org.springframework.ide.vscode.commons.languageserver.reconcile.ICollector;
33-
import org.springframework.ide.vscode.commons.languageserver.util.LspClient;
34-
import org.springframework.ide.vscode.commons.languageserver.util.LspClient.Client;
35-
import org.springframework.ide.vscode.commons.protocol.java.ProjectBuild;
3632
import org.springframework.ide.vscode.commons.util.text.IRegion;
3733
import org.springframework.ide.vscode.commons.util.text.TextDocument;
3834

@@ -56,11 +52,6 @@ public boolean isApplicable(IJavaProject project) {
5652
}
5753

5854
static boolean isValidProject(IJavaProject project) {
59-
IProjectBuild build = project.getProjectBuild();
60-
if (LspClient.currentClient() == Client.VSCODE && build != null && ProjectBuild.GRADLE_PROJECT_TYPE.equals(build.getType())) {
61-
// TODO: remove once `gradle.runBuild` of vscode-gradle takes the arguments of the AOT refresh command (GH-1722)
62-
return false;
63-
}
6455
Version springDataJpaVersion = SpringProjectUtil.getDependencyVersionByPrefix(project, "spring-data-jpa");
6556
Version springDataMongoDbVersion = SpringProjectUtil.getDependencyVersionByPrefix(project, "spring-data-mongodb");
6657
Version springDataJddbcVersion = SpringProjectUtil.getDependencyVersionByPrefix(project, "spring-data-jdbc");

‎headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/GradleBuildCommandTest.java‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ private void assertCommand(Command cmd, String commandId, int argCount) {
6262
void vscodeAndEclipseRunTheBuildWithTheirGradleSupport() {
6363
// vscode-gradle: gradle.runBuild(buildFile, command, env); Eclipse: handled by the Buildship launch of the Eclipse client
6464
Command cmd = new VSCodeBuildCommandProvider().executeGradleBuild(project(), "classes aotClasses");
65-
assertCommand(cmd, "gradle.runBuild", 4);
66-
// the client reloads the project after the build: the generated folders become source folders
67-
assertEquals(Map.of("refreshJavaProject", true), cmd.getArguments().get(3));
65+
assertCommand(cmd, "gradle.runBuild", 3);
6866
}
6967

7068
@Test

‎headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/data/DataRepositoryAotMetadataServiceRefreshCommandTest.java‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -160,19 +160,4 @@ void clientWithoutSupportGetsNoCommand() throws Exception {
160160
assertFalse(service.regenerateMetadataCommand(project).isPresent());
161161
}
162162

163-
@Test
164-
void gradleProjectsAreNotValidInVSCodeUntilVSCodeGradleSupportsTheCommand() throws Exception {
165-
String client = System.getProperty("sts.lsp.client");
166-
System.setProperty("sts.lsp.client", "vscode");
167-
try {
168-
assertFalse(QueryMethodCodeActionProvider.isValidProject(gradleProject("spring-boot-4.0.0.jar", projectDir.toFile())));
169-
} finally {
170-
if (client == null) {
171-
System.clearProperty("sts.lsp.client");
172-
} else {
173-
System.setProperty("sts.lsp.client", client);
174-
}
175-
}
176-
}
177-
178163
}

0 commit comments

Comments
 (0)