From e3a9052896a9047ef39b3e8b8ab398de28b4ae27 Mon Sep 17 00:00:00 2001 From: Martin Lippert Date: Sat, 27 Apr 2019 14:41:57 +0200 Subject: [PATCH] first steps towards deploying and running language servers in exloded format directly from a dir-shaped bundle --- .gitignore | 1 + .../META-INF/MANIFEST.MF | 1 + .../about.html | 4 +- .../pom.xml | 38 +++------------ .../boot/ls/SpringBootLanguageServer.java | 47 ++++++++++++++++++- 5 files changed, 55 insertions(+), 36 deletions(-) diff --git a/.gitignore b/.gitignore index 2a6a7adb4..c6f84e1ed 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ eclipse-language-servers/**/*.jar # virtual machine crash logs, see https://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* +servers/ target/ bin/ *.log diff --git a/eclipse-language-servers/org.springframework.tooling.boot.ls/META-INF/MANIFEST.MF b/eclipse-language-servers/org.springframework.tooling.boot.ls/META-INF/MANIFEST.MF index b04744266..41c86ed18 100644 --- a/eclipse-language-servers/org.springframework.tooling.boot.ls/META-INF/MANIFEST.MF +++ b/eclipse-language-servers/org.springframework.tooling.boot.ls/META-INF/MANIFEST.MF @@ -32,3 +32,4 @@ Import-Package: com.google.gson;version="2.7.0", org.osgi.framework Bundle-Activator: org.springframework.tooling.boot.ls.BootLanguageServerPlugin Bundle-ActivationPolicy: lazy +Eclipse-BundleShape: dir diff --git a/eclipse-language-servers/org.springframework.tooling.boot.ls/about.html b/eclipse-language-servers/org.springframework.tooling.boot.ls/about.html index 009b0b365..aa8c1d9e3 100644 --- a/eclipse-language-servers/org.springframework.tooling.boot.ls/about.html +++ b/eclipse-language-servers/org.springframework.tooling.boot.ls/about.html @@ -18,8 +18,8 @@ mean the Content.

Third Party Content

The exact license information of the contained language server can be found at - META-INF/third-party-open-source-licenses.txt (for an overview of used open-source components) and - META-INF/third-party-open-source-licenses/ + servers/spring-boot-language-server/META-INF/third-party-open-source-licenses.txt (for an overview of used open-source components) and + servers/spring-boot-language-server/META-INF/third-party-open-source-licenses/

diff --git a/eclipse-language-servers/org.springframework.tooling.boot.ls/pom.xml b/eclipse-language-servers/org.springframework.tooling.boot.ls/pom.xml index 05702eb92..a0c15c763 100644 --- a/eclipse-language-servers/org.springframework.tooling.boot.ls/pom.xml +++ b/eclipse-language-servers/org.springframework.tooling.boot.ls/pom.xml @@ -15,14 +15,6 @@ 1.7.0-SNAPSHOT eclipse-plugin - - - org.springframework.ide.vscode - spring-boot-language-server - 1.7.0-SNAPSHOT - - - @@ -31,27 +23,7 @@ 3.1.1 - copy - prepare-package - - copy - - - - - org.springframework.ide.vscode - spring-boot-language-server - true - ${project.build.directory}/../servers - - - true - true - - - - - unpack + unpack-server prepare-package unpack @@ -61,11 +33,13 @@ org.springframework.ide.vscode spring-boot-language-server - + 1.7.0-SNAPSHOT + true - META-INF/third-party-open-source-licenses.txt,META-INF/third-party-open-source-licenses/**.* - ${project.build.directory}/../ + true + true + ${project.build.directory}/../servers/spring-boot-language-server diff --git a/eclipse-language-servers/org.springframework.tooling.boot.ls/src/org/springframework/tooling/boot/ls/SpringBootLanguageServer.java b/eclipse-language-servers/org.springframework.tooling.boot.ls/src/org/springframework/tooling/boot/ls/SpringBootLanguageServer.java index 233728f57..e117abd35 100644 --- a/eclipse-language-servers/org.springframework.tooling.boot.ls/src/org/springframework/tooling/boot/ls/SpringBootLanguageServer.java +++ b/eclipse-language-servers/org.springframework.tooling.boot.ls/src/org/springframework/tooling/boot/ls/SpringBootLanguageServer.java @@ -12,11 +12,18 @@ package org.springframework.tooling.boot.ls; import static org.springframework.tooling.ls.eclipse.commons.preferences.LanguageServerConsolePreferenceConstants.SPRING_BOOT_SERVER; +import java.io.File; import java.util.ArrayList; import java.util.List; +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.Platform; +import org.osgi.framework.Bundle; import org.springframework.tooling.ls.eclipse.commons.JRE; import org.springframework.tooling.ls.eclipse.commons.JRE.MissingJDKException; + +import com.google.common.collect.ImmutableList; + import org.springframework.tooling.ls.eclipse.commons.STS4LanguageServerProcessStreamConnector; /** @@ -26,8 +33,43 @@ public class SpringBootLanguageServer extends STS4LanguageServerProcessStreamCon public SpringBootLanguageServer() { super(SPRING_BOOT_SERVER); - setCommands(getJRE().jarLaunchCommand(getLanguageServerJARLocation(), - getJVMArgs())); + + try { + ImmutableList.Builder command = ImmutableList.builder(); + JRE runtime = getJRE(); + + command.add(runtime.getJavaExecutable()); + command.add("-cp"); + + Bundle bundle = Platform.getBundle(getPluginId()); + File bundleFile = FileLocator.getBundleFile(bundle); + + String bundleRoot = bundleFile.getAbsoluteFile().toString(); + String languageServerRoot = bundleRoot + File.separator + "servers" + File.separator + "spring-boot-language-server" + File.separator; + + StringBuilder classpath = new StringBuilder(languageServerRoot); + classpath.append("BOOT-INF" + File.separator + "classes"); + classpath.append(File.pathSeparator); + classpath.append(languageServerRoot); + classpath.append("BOOT-INF" + File.separator + "lib" + File.separator + "*"); + + if (runtime.toolsJar != null) { + classpath.append(File.pathSeparator); + classpath.append(runtime.toolsJar); + } + + command.add(classpath.toString()); + + command.addAll(getJVMArgs()); + + command.add("org.springframework.ide.vscode.boot.app.BootLanguagServerBootApp"); + setCommands(command.build()); + } + catch (Exception e) { + // error + e.printStackTrace(); + } + setWorkingDirectory(getWorkingDirLocation()); } @@ -39,6 +81,7 @@ public class SpringBootLanguageServer extends STS4LanguageServerProcessStreamCon args.add("-Dsts.lsp.client=eclipse"); args.add("-Dlsp.completions.indentation.enable=true"); args.add("-Xmx1024m"); + args.add("-noverify"); addCustomJVMArgs(args);