New LS JAR layout for vscode and eclipse extensions

This commit is contained in:
aboyko
2024-07-26 22:17:19 -04:00
parent 32c8a86d86
commit df9fbcdc0c
21 changed files with 345 additions and 99 deletions

View File

@@ -22,11 +22,12 @@
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>unpack-server</id>
<id>copy-server</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
@@ -40,9 +41,29 @@
</artifactItems>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<outputDirectory>${project.build.directory}/../servers/spring-boot-language-server</outputDirectory>
<outputDirectory>${project.basedir}/servers</outputDirectory>
</configuration>
</execution>
<execution>
<id>problem-types.json</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>spring-boot-language-server</artifactId>
<version>${project.version}</version>
<outputDirectory>${project.basedir}/servers/spring-boot-language-server</outputDirectory>
<includes>**/problem-types.json</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
<execution>
<id>xml-extension</id>
<phase>prepare-package</phase>
@@ -67,7 +88,57 @@
<stripVersion>true</stripVersion>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<outputDirectory>${project.build.directory}/../jars</outputDirectory>
<outputDirectory>${project.basedir}/jars</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>extract</id>
<phase>prepare-package</phase>
<configuration>
<executable>java</executable>
<arguments>
<argument>-Djarmode=tools</argument>
<argument>-jar</argument>
<argument>${project.basedir}/servers/spring-boot-language-server-${project.version}-exec.jar</argument>
<argument>extract</argument>
<argument>--force</argument>
<argument>--destination</argument>
<argument>${project.basedir}/servers/spring-boot-language-server</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<delete>
<fileset
dir="${project.basedir}/servers"
includes="spring-boot-language-server-${project.version}-exec.jar" />
</delete>
</target>
</configuration>
</execution>
</executions>

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2021 Pivotal, Inc.
* Copyright (c) 2017, 2024 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -28,10 +28,9 @@ public class SpringBootLanguageServer extends STS4LanguageServerProcessStreamCon
public SpringBootLanguageServer() {
super(SPRING_BOOT_SERVER);
initExplodedJarCommand(
initExecutableJarCommand(
Paths.get("servers", "spring-boot-language-server"),
"org.springframework.ide.vscode.boot.app.BootLanguageServerBootApp",
"application.properties",
"spring-boot-language-server",
getJVMArgs()
);

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2022 Pivotal, Inc.
* Copyright (c) 2020, 2024 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -27,7 +27,7 @@ public class LanguageServerProblemTypesMetadata {
public static List<ProblemCategoryData> load() throws IOException {
File root = FileLocator.getBundleFile(BootLanguageServerPlugin.getDefault().getBundle());
File metadataFile = root.toPath().resolve("servers/spring-boot-language-server/BOOT-INF/classes/problem-types.json").toFile();
File metadataFile = root.toPath().resolve("servers/spring-boot-language-server/problem-types.json").toFile();
return readCategoriesFromFile(metadataFile);
}

View File

@@ -24,10 +24,10 @@
<version>3.1.1</version>
<executions>
<execution>
<id>unpack-server</id>
<id>copy-server</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
@@ -41,7 +41,7 @@
</artifactItems>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<outputDirectory>${project.build.directory}/../servers/bosh-language-server</outputDirectory>
<outputDirectory>${project.basedir}/servers</outputDirectory>
</configuration>
</execution>
@@ -68,6 +68,56 @@
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>extract</id>
<phase>prepare-package</phase>
<configuration>
<executable>java</executable>
<arguments>
<argument>-Djarmode=tools</argument>
<argument>-jar</argument>
<argument>${project.basedir}/servers/bosh-language-server-${project.version}-exec.jar</argument>
<argument>extract</argument>
<argument>--force</argument>
<argument>--destination</argument>
<argument>${project.basedir}/servers/bosh-language-server</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<delete>
<fileset
dir="${project.basedir}/servers"
includes="bosh-language-server-${project.version}-exec.jar" />
</delete>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2019 Pivotal, Inc.
* Copyright (c) 2016, 2024 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -25,16 +25,15 @@ public class BoshLanguageServer extends STS4LanguageServerProcessStreamConnector
public BoshLanguageServer() {
super(BOSH_SERVER);
initExplodedJarCommand(
initExecutableJarCommand(
Paths.get("servers", "bosh-language-server"),
"org.springframework.ide.vscode.bosh.BoshLanguageServerBootApp",
"application.properties",
"bosh-language-server",
Arrays.asList(
"-Dlsp.lazy.completions.disable=true",
"-XX:TieredStopAtLevel=1"
)
);
setWorkingDirectory(getWorkingDirLocation());
}

View File

@@ -24,10 +24,10 @@
<version>3.1.1</version>
<executions>
<execution>
<id>unpack-server</id>
<id>copy-server</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
@@ -41,7 +41,7 @@
</artifactItems>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<outputDirectory>${project.build.directory}/../servers/manifest-yaml-language-server</outputDirectory>
<outputDirectory>${project.basedir}/servers</outputDirectory>
</configuration>
</execution>
@@ -68,6 +68,56 @@
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>extract</id>
<phase>prepare-package</phase>
<configuration>
<executable>java</executable>
<arguments>
<argument>-Djarmode=tools</argument>
<argument>-jar</argument>
<argument>${project.basedir}/servers/manifest-yaml-language-server-${project.version}-exec.jar</argument>
<argument>extract</argument>
<argument>--force</argument>
<argument>--destination</argument>
<argument>${project.basedir}/servers/manifest-yaml-language-server</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<delete>
<fileset
dir="${project.basedir}/servers"
includes="manifest-yaml-language-server-${project.version}-exec.jar" />
</delete>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2020 Pivotal, Inc.
* Copyright (c) 2016, 2024 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -41,16 +41,15 @@ public class CloudFoundryManifestLanguageServer extends STS4LanguageServerProces
public CloudFoundryManifestLanguageServer() {
super(CLOUDFOUNDRY_SERVER);
initExplodedJarCommand(
initExecutableJarCommand(
Paths.get("servers", "manifest-yaml-language-server"),
"org.springframework.ide.vscode.manifest.yaml.ManifestYamlLanguageServerBootApp",
"application.properties",
"manifest-yaml-language-server",
Arrays.asList(
"-Dlsp.lazy.completions.disable=true",
"-XX:TieredStopAtLevel=1"
)
);
setWorkingDirectory(getWorkingDirLocation());
}

View File

@@ -24,10 +24,10 @@
<version>2.10</version>
<executions>
<execution>
<id>unpack-server</id>
<id>copy-server</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
@@ -41,7 +41,7 @@
</artifactItems>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<outputDirectory>${project.build.directory}/../servers/concourse-language-server</outputDirectory>
<outputDirectory>${project.basedir}/servers</outputDirectory>
</configuration>
</execution>
@@ -68,6 +68,56 @@
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>extract</id>
<phase>prepare-package</phase>
<configuration>
<executable>java</executable>
<arguments>
<argument>-Djarmode=tools</argument>
<argument>-jar</argument>
<argument>${project.basedir}/servers/concourse-language-server-${project.version}-exec.jar</argument>
<argument>extract</argument>
<argument>--force</argument>
<argument>--destination</argument>
<argument>${project.basedir}/servers/concourse-language-server</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<delete>
<fileset
dir="${project.basedir}/servers"
includes="concourse-language-server-${project.version}-exec.jar" />
</delete>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2019 Pivotal, Inc.
* Copyright (c) 2016, 2024 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -24,11 +24,10 @@ public class ConcourseLanguageServer extends STS4LanguageServerProcessStreamConn
public ConcourseLanguageServer() {
super(CONCOURSE_SERVER);
initExplodedJarCommand(
initExecutableJarCommand(
Paths.get("servers", "concourse-language-server"),
"org.springframework.ide.vscode.concourse.ConcourseLanguageServerBootApp",
"application.properties",
"concourse-language-server",
Arrays.asList(
"-Dlsp.lazy.completions.disable=true",
"-XX:TieredStopAtLevel=1"

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2023 Pivotal, Inc.
* Copyright (c) 2017, 2024 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,9 +14,11 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.FileLocator;
@@ -80,6 +82,72 @@ public abstract class STS4LanguageServerProcessStreamConnector extends ProcessSt
return JRE.currentJRE();
}
protected final void initExecutableJarCommand(Path lsDir, String jarPrefix, List<String> extraVmArgs) {
try {
Bundle bundle = Platform.getBundle(getPluginId());
JRE runtime = getJRE();
Assert.isNotNull(lsDir);
File bundleFile = FileLocator.getBundleFileLocation(bundle).orElse(null);
File bundleRoot = bundleFile.getAbsoluteFile();
Path languageServerRoot = bundleRoot.toPath().resolve(lsDir);
List<Path> jarFiles = Files.list(languageServerRoot).filter(Files::isRegularFile).filter(f -> {
String fileName = f.toFile().getName();
return fileName.endsWith(".jar") && fileName.startsWith(jarPrefix);
}).limit(2).collect(Collectors.toList());
if (jarFiles.size() > 1) {
throw new IllegalStateException("More than one LS JAR files found: '%s' and '%s'".formatted(jarFiles.get(0), jarFiles.get(1)));
} else if (jarFiles.isEmpty()) {
throw new IllegalStateException("No LS JAR files found!");
}
Path jarFile = jarFiles.get(0);
List<String> command = new ArrayList<>();
command.add(runtime.getJavaExecutable());
command.add("-jar");
command.add(languageServerRoot.resolve(jarFile).toFile().toString());
fillCommand(command, extraVmArgs);
setCommands(command);
LanguageServerCommonsActivator.getInstance().getLog().info("Command list starting LS: " + connectorId + "\nSTART:\n" + String.join("\n", command) + "\nEND");
} catch (Throwable t) {
LanguageServerCommonsActivator.logError(t, "Failed to assemble executable LS JAR launch command");
}
}
private void fillCommand(List<String> command, List<String> extraVmArgs) {
command.add("-Dsts.lsp.client=eclipse");
command.addAll(extraVmArgs);
if (!hasVmArgStartingWith(command, LOG_RESOLVE_VM_ARG_PREFIX)) {
command.add(LOG_RESOLVE_VM_ARG_PREFIX + "off");
}
LsPreferencesUtil.getServerInfo(getPluginId()).ifPresent(info -> {
IPreferenceStore preferenceStore = LanguageServerCommonsActivator.getInstance().getPreferenceStore();
if (!preferenceStore.getBoolean(info.preferenceKeyConsoleLog)) {
String pathStr = preferenceStore.getString(info.preferenceKeyFileLog);
if (pathStr != null && !pathStr.isBlank()) {
command.add("-Dsts.log.file=" + pathStr);
}
}
command.add("-XX:ErrorFile=" + Platform.getStateLocation(Platform.getBundle(getPluginId())).append("fatal-error-" + info.label.replaceAll("\\s+", "-").toLowerCase() + "_" + System.currentTimeMillis()));
});
command.add("-Dlanguageserver.hover-timeout=225");
}
protected final void initExplodedJarCommand(Path lsFolder, String mainClass, String configFileName, List<String> extraVmArgs) {
try {
Bundle bundle = Platform.getBundle(getPluginId());
@@ -113,39 +181,20 @@ public abstract class STS4LanguageServerProcessStreamConnector extends ProcessSt
command.add(classpath.toString());
command.add("-Dsts.lsp.client=eclipse");
command.addAll(extraVmArgs);
if (!hasVmArgStartingWith(command, LOG_RESOLVE_VM_ARG_PREFIX)) {
command.add(LOG_RESOLVE_VM_ARG_PREFIX + "off");
}
if (configFileName != null) {
command.add("-Dspring.config.location=file:" + languageServerRoot.resolve("BOOT-INF/classes").resolve(configFileName).toFile());
}
LsPreferencesUtil.getServerInfo(getPluginId()).ifPresent(info -> {
IPreferenceStore preferenceStore = LanguageServerCommonsActivator.getInstance().getPreferenceStore();
if (!preferenceStore.getBoolean(info.preferenceKeyConsoleLog)) {
String pathStr = preferenceStore.getString(info.preferenceKeyFileLog);
if (pathStr != null && !pathStr.isBlank()) {
command.add("-Dsts.log.file=" + pathStr);
}
}
command.add("-XX:ErrorFile=" + Platform.getStateLocation(bundle).append("fatal-error-" + info.label.replaceAll("\\s+", "-").toLowerCase() + "_" + System.currentTimeMillis()));
});
fillCommand(command, extraVmArgs);
command.add(mainClass);
command.add("--languageserver.hover-timeout=225");
setCommands(command);
LanguageServerCommonsActivator.getInstance().getLog().info("Command list starting LS: " + connectorId + "\nSTART:\n" + String.join("\n", command) + "\nEND");
}
catch (Exception e) {
LanguageServerCommonsActivator.logError(e, "Failed to assemble exploded LS JAR launch command");
catch (Throwable t) {
LanguageServerCommonsActivator.logError(t, "Failed to assemble exploded LS JAR launch command");
}
}