PT #165890357: Adopt exploded LS jar for all eclipse LSs

This commit is contained in:
BoykoAlex
2019-05-10 17:15:11 -04:00
parent 087f504691
commit d037b41903
17 changed files with 178 additions and 104 deletions

View File

@@ -75,7 +75,17 @@
</dependency-resolution>
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<filesets>
<fileset>
<directory>servers</directory>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
</build>

View File

@@ -12,18 +12,12 @@ 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.nio.file.Paths;
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;
/**
@@ -34,47 +28,12 @@ public class SpringBootLanguageServer extends STS4LanguageServerProcessStreamCon
public SpringBootLanguageServer() {
super(SPRING_BOOT_SERVER);
try {
ImmutableList.Builder<String> 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());
StringBuilder configLocation = new StringBuilder(languageServerRoot);
configLocation.append("BOOT-INF" + File.separator + "classes");
configLocation.append(File.separator);
configLocation.append("application.properties");
command.add("-Dspring.config.location=file:" + configLocation.toString());
command.add("org.springframework.ide.vscode.boot.app.BootLanguagServerBootApp");
setCommands(command.build());
}
catch (Exception e) {
// error
e.printStackTrace();
}
initExplodedJarCommand(
Paths.get("servers", "spring-boot-language-server"),
"org.springframework.ide.vscode.boot.app.BootLanguagServerBootApp",
"application.properties",
getJVMArgs()
);
setWorkingDirectory(getWorkingDirLocation());
}
@@ -82,7 +41,6 @@ public class SpringBootLanguageServer extends STS4LanguageServerProcessStreamCon
private List<String> getJVMArgs() {
List<String> args = new ArrayList<>();
args.add("-Dsts.lsp.client=eclipse");
args.add("-Dlsp.completions.indentation.enable=true");
args.add("-Xmx1024m");
args.add("-noverify");
@@ -105,7 +63,7 @@ public class SpringBootLanguageServer extends STS4LanguageServerProcessStreamCon
}
}
private JRE getJRE() {
protected JRE getJRE() {
try {
return JRE.findJRE(true);
} catch (MissingJDKException e) {

View File

@@ -36,10 +36,10 @@
<version>3.1.1</version>
<executions>
<execution>
<id>copy</id>
<id>unpack-server</id>
<phase>prepare-package</phase>
<goals>
<goal>copy</goal>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
@@ -49,11 +49,11 @@
<version>${project.version}</version>
<classifier>exec</classifier>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/../servers</outputDirectory>
</artifactItem>
</artifactItems>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<outputDirectory>${project.build.directory}/../servers/bosh-language-server</outputDirectory>
</configuration>
</execution>
@@ -79,6 +79,17 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<filesets>
<fileset>
<directory>servers</directory>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
</build>

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2017 Pivotal, Inc.
* Copyright (c) 2016, 2019 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
@@ -12,10 +12,10 @@ package org.springframework.tooling.bosh.ls;
import static org.springframework.tooling.ls.eclipse.commons.preferences.LanguageServerConsolePreferenceConstants.BOSH_SERVER;
import org.springframework.tooling.ls.eclipse.commons.JRE;
import org.springframework.tooling.ls.eclipse.commons.STS4LanguageServerProcessStreamConnector;
import java.nio.file.Paths;
import java.util.Arrays;
import com.google.common.collect.ImmutableList;
import org.springframework.tooling.ls.eclipse.commons.STS4LanguageServerProcessStreamConnector;
/**
* @author Martin Lippert
@@ -24,12 +24,18 @@ public class BoshLanguageServer extends STS4LanguageServerProcessStreamConnector
public BoshLanguageServer() {
super(BOSH_SERVER);
setCommands(JRE.currentJRE().jarLaunchCommand(getLanguageServerJARLocation(), ImmutableList.of(
//"-Xdebug",
//"-agentlib:jdwp=transport=dt_socket,address=8899,server=y,suspend=n",
"-Dlsp.lazy.completions.disable=true",
"-Dlsp.completions.indentation.enable=true"
)));
initExplodedJarCommand(
Paths.get("servers", "bosh-language-server"),
"org.springframework.ide.vscode.bosh.BoshLanguageServerBootApp",
"application.properties",
Arrays.asList(
"-Dlsp.lazy.completions.disable=true",
"-Dlsp.completions.indentation.enable=true",
"-noverify"
)
);
setWorkingDirectory(getWorkingDirLocation());
}

View File

@@ -36,10 +36,10 @@
<version>3.1.1</version>
<executions>
<execution>
<id>copy</id>
<id>unpack-server</id>
<phase>prepare-package</phase>
<goals>
<goal>copy</goal>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
@@ -49,11 +49,11 @@
<version>${project.version}</version>
<classifier>exec</classifier>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/../servers</outputDirectory>
</artifactItem>
</artifactItems>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<outputDirectory>${project.build.directory}/../servers/manifest-yaml-language-server</outputDirectory>
</configuration>
</execution>
@@ -79,6 +79,17 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<filesets>
<fileset>
<directory>servers</directory>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
</build>

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2017 Pivotal, Inc.
* Copyright (c) 2016, 2019 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
@@ -13,6 +13,8 @@ package org.springframework.tooling.cloudfoundry.manifest.ls;
import static org.springframework.tooling.ls.eclipse.commons.preferences.LanguageServerConsolePreferenceConstants.CLOUDFOUNDRY_SERVER;
import java.net.URI;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -21,11 +23,8 @@ import org.eclipse.lsp4j.InitializeResult;
import org.eclipse.lsp4j.jsonrpc.messages.Message;
import org.eclipse.lsp4j.jsonrpc.messages.ResponseMessage;
import org.eclipse.lsp4j.services.LanguageServer;
import org.springframework.tooling.ls.eclipse.commons.JRE;
import org.springframework.tooling.ls.eclipse.commons.STS4LanguageServerProcessStreamConnector;
import com.google.common.collect.ImmutableList;
/**
* @author Martin Lippert
*/
@@ -39,12 +38,18 @@ public class CloudFoundryManifestLanguageServer extends STS4LanguageServerProces
public CloudFoundryManifestLanguageServer() {
super(CLOUDFOUNDRY_SERVER);
setCommands(JRE.currentJRE().jarLaunchCommand(getLanguageServerJARLocation(), ImmutableList.of(
//"-Xdebug",
//"-agentlib:jdwp=transport=dt_socket,address=8899,server=y,suspend=n",
"-Dlsp.lazy.completions.disable=true",
"-Dlsp.completions.indentation.enable=true"
)));
initExplodedJarCommand(
Paths.get("servers", "manifest-yaml-language-server"),
"org.springframework.ide.vscode.manifest.yaml.ManifestYamlLanguageServerBootApp",
"application.properties",
Arrays.asList(
"-Dlsp.lazy.completions.disable=true",
"-Dlsp.completions.indentation.enable=true",
"-noverify"
)
);
setWorkingDirectory(getWorkingDirLocation());
}

View File

@@ -36,10 +36,10 @@
<version>2.10</version>
<executions>
<execution>
<id>copy</id>
<id>unpack-server</id>
<phase>prepare-package</phase>
<goals>
<goal>copy</goal>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
@@ -49,11 +49,11 @@
<version>${project.version}</version>
<classifier>exec</classifier>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/../servers</outputDirectory>
</artifactItem>
</artifactItems>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<outputDirectory>${project.build.directory}/../servers/concourse-language-server</outputDirectory>
</configuration>
</execution>
@@ -79,6 +79,17 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<filesets>
<fileset>
<directory>servers</directory>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
</build>

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2017 Pivotal, Inc.
* Copyright (c) 2016, 2019 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
@@ -12,10 +12,10 @@ package org.springframework.tooling.concourse.ls;
import static org.springframework.tooling.ls.eclipse.commons.preferences.LanguageServerConsolePreferenceConstants.CONCOURSE_SERVER;
import org.springframework.tooling.ls.eclipse.commons.JRE;
import org.springframework.tooling.ls.eclipse.commons.STS4LanguageServerProcessStreamConnector;
import java.nio.file.Paths;
import java.util.Arrays;
import com.google.common.collect.ImmutableList;
import org.springframework.tooling.ls.eclipse.commons.STS4LanguageServerProcessStreamConnector;
/**
* @author Martin Lippert
@@ -24,12 +24,18 @@ public class ConcourseLanguageServer extends STS4LanguageServerProcessStreamConn
public ConcourseLanguageServer() {
super(CONCOURSE_SERVER);
setCommands(JRE.currentJRE().jarLaunchCommand(getLanguageServerJARLocation(), ImmutableList.of(
//"-Xdebug",
//"-agentlib:jdwp=transport=dt_socket,address=8899,server=y,suspend=n",
"-Dlsp.lazy.completions.disable=true",
"-Dlsp.completions.indentation.enable=true"
)));
initExplodedJarCommand(
Paths.get("servers", "concourse-language-server"),
"org.springframework.ide.vscode.concourse.ConcourseLanguageServerBootApp",
"application.properties",
Arrays.asList(
"-Dlsp.lazy.completions.disable=true",
"-Dlsp.completions.indentation.enable=true",
"-noverify"
)
);
setWorkingDirectory(getWorkingDirLocation());
}

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2018 Pivotal, Inc.
* Copyright (c) 2017, 2019 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
@@ -15,12 +15,14 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.List;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
@@ -34,6 +36,7 @@ import org.springsource.ide.eclipse.commons.core.util.IOUtil;
import com.google.common.base.Charsets;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableList;
public abstract class STS4LanguageServerProcessStreamConnector extends ProcessStreamConnectionProvider {
@@ -69,11 +72,64 @@ public abstract class STS4LanguageServerProcessStreamConnector extends ProcessSt
}
}
}.start();;
}.start();
}
}
}
protected JRE getJRE() {
return JRE.currentJRE();
}
protected final void initExplodedJarCommand(Path lsFolder, String mainClass, String configFileName, List<String> extraVmArgs) {
try {
Assert.isNotNull(lsFolder);
Assert.isNotNull(mainClass);
ImmutableList.Builder<String> command = ImmutableList.builder();
JRE runtime = getJRE();
command.add(runtime.getJavaExecutable());
command.add("-cp");
Bundle bundle = Platform.getBundle(getPluginId());
File bundleFile = FileLocator.getBundleFile(bundle);
File bundleRoot = bundleFile.getAbsoluteFile();
Path languageServerRoot = bundleRoot.toPath().resolve(lsFolder);
StringBuilder classpath = new StringBuilder();
classpath.append(languageServerRoot.resolve("BOOT-INF/classes").toFile());
classpath.append(File.pathSeparator);
classpath.append(languageServerRoot.resolve("BOOT-INF/lib").toFile());
// Cannot have * in the java.nio.Path on Windows
classpath.append(File.separator);
classpath.append('*');
if (runtime.toolsJar != null) {
classpath.append(File.pathSeparator);
classpath.append(runtime.toolsJar);
}
command.add(classpath.toString());
command.add("-Dsts.lsp.client=eclipse");
command.addAll(extraVmArgs);
if (configFileName != null) {
command.add("-Dspring.config.location=file:" + languageServerRoot.resolve("BOOT-INF/classes").resolve(configFileName).toFile());
}
command.add(mainClass);
setCommands(command.build());
}
catch (Exception e) {
LanguageServerCommonsActivator.logError(e, "Failed to assemble exploded LS JAR launch command");
}
}
@Override
protected ProcessBuilder createProcessBuilder() {
if (consoles==null) {
@@ -195,7 +251,7 @@ public abstract class STS4LanguageServerProcessStreamConnector extends ProcessSt
protected final void copyLanguageServerJAR(String languageServerJarName, String languageServerLocalCopy) throws Exception {
Bundle bundle = Platform.getBundle(getPluginId());
InputStream stream = FileLocator.openStream( bundle, new Path("servers/" + languageServerJarName), false );
InputStream stream = FileLocator.openStream( bundle, new org.eclipse.core.runtime.Path("servers/" + languageServerJarName), false );
File dataFile = bundle.getDataFile(languageServerLocalCopy);
Files.copy(stream, dataFile.toPath(), StandardCopyOption.REPLACE_EXISTING);

View File

@@ -0,0 +1,2 @@
languageserver.extension-id=vscode-bosh
spring.main.banner-mode=off

View File

@@ -1,2 +0,0 @@
languageserver:
extension-id: vscode-bosh

View File

@@ -1 +1,2 @@
spring.main.banner-mode=off
languageserver.extension-id=vscode-bosh
spring.main.banner-mode=off

View File

@@ -0,0 +1,2 @@
languageserver.extension-id=vscode-concourse
spring.main.banner-mode=off

View File

@@ -1,2 +0,0 @@
languageserver:
extension-id: vscode-concourse

View File

@@ -1,2 +1,3 @@
spring.main.banner-mode=off
languageserver.extension-id=vscode-concourse
logging.level.org.springframework.ide.vscode=debug

View File

@@ -0,0 +1,3 @@
#logging.level.org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer=debug
languageserver.extension-id=vscode-manifest-yaml
spring.main.banner-mode=off

View File

@@ -1,5 +0,0 @@
#logging:
# level:
# org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer: debug
languageserver:
extension-id: vscode-manifest-yaml