Revert "Slight;y better logic to look for tools.jar"
This reverts commit bab9f98d9b.
This commit is contained in:
@@ -39,13 +39,7 @@ public class SpringBootJavaLanguageServer extends STS4LanguageServerProcessStrea
|
||||
commands.add("-Dlsp.completions.indentation.enable=true");
|
||||
commands.add("-Xmx1024m");
|
||||
commands.add("-cp");
|
||||
File toolsJar = getToolsJAR();
|
||||
if (toolsJar!=null) {
|
||||
commands.add(toolsJar + File.pathSeparator + getLanguageServerJARLocation());
|
||||
} else {
|
||||
//TODO: issue a 'missing tools.jar warning somehow depending on the platform?
|
||||
commands.add(getLanguageServerJARLocation());
|
||||
}
|
||||
commands.add(getToolsJAR() + File.pathSeparator + getLanguageServerJARLocation());
|
||||
commands.add("org.springframework.boot.loader.JarLauncher");
|
||||
|
||||
String workingDir = getWorkingDirLocation();
|
||||
|
||||
@@ -12,11 +12,8 @@ package org.springframework.tooling.ls.eclipse.commons;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.jdt.internal.launching.StandardVMType;
|
||||
import org.eclipse.lsp4e.server.ProcessStreamConnectionProvider;
|
||||
|
||||
@@ -53,58 +50,11 @@ public class STS4LanguageServerProcessStreamConnector extends ProcessStreamConne
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Different places to look for tools jar, relative to Java home.
|
||||
*/
|
||||
private static String [] TOOLS_JAR_PATHS = {
|
||||
"../lib/tools.jar",
|
||||
"lib/tools.jar"
|
||||
};
|
||||
|
||||
protected File getToolsJAR() {
|
||||
List<File> jhomes = new ArrayList<>(2);
|
||||
resolve(System.getenv("JAVA_HOME"), jhomes::add);
|
||||
resolve(System.getProperty("java.home"), jhomes::add);
|
||||
for (File jhome : jhomes) {
|
||||
for (String tjPath : TOOLS_JAR_PATHS) {
|
||||
File toolsJar = new File(jhome, tjPath);
|
||||
if (toolsJar.isFile()) {
|
||||
return toolsJar;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
protected String getToolsJAR() {
|
||||
File jre = new File(System.getProperty("java.home"));
|
||||
return new File(jre.getParent(), "lib" + Path.SEPARATOR + "tools.jar").getAbsolutePath();
|
||||
}
|
||||
|
||||
private void resolve(String path, Consumer<File> requestor) {
|
||||
if (path!=null) {
|
||||
try {
|
||||
File file = new File(path).getCanonicalFile();
|
||||
if (file.exists()) {
|
||||
requestor.accept(file);
|
||||
return;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
//Ignore... this can happen because it tries to handle symbolic links
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private File getJavaHomeFromEnv() {
|
||||
try {
|
||||
File jhome = new File(System.getenv("JAVA_HOME"));
|
||||
if (jhome!=null) {
|
||||
jhome = jhome.getCanonicalFile();
|
||||
if (jhome.isDirectory()) {
|
||||
return jhome;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
//Ignore... this can happen because it tries to handle symbolic links
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String getWorkingDirLocation() {
|
||||
return System.getProperty("user.dir");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user