Add warning message in Eclipse for missing tools.jar on boot-java ls
This commit is contained in:
@@ -12,14 +12,27 @@ package org.springframework.tooling.ls.eclipse.commons;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.jdt.internal.launching.StandardVMType;
|
||||
import org.eclipse.lsp4e.server.ProcessStreamConnectionProvider;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public class STS4LanguageServerProcessStreamConnector extends ProcessStreamConnectionProvider {
|
||||
|
||||
public static class MissingToolsJarException extends Exception {
|
||||
|
||||
public final File javaHome;
|
||||
public final List<File> lookedIn;
|
||||
|
||||
public MissingToolsJarException(File javaHome, List<File> lookedIn) {
|
||||
super();
|
||||
this.javaHome = javaHome;
|
||||
this.lookedIn = lookedIn;
|
||||
}
|
||||
}
|
||||
|
||||
private static LanguageServerProcessReaper processReaper = new LanguageServerProcessReaper();
|
||||
|
||||
@Override
|
||||
@@ -50,9 +63,32 @@ public class STS4LanguageServerProcessStreamConnector extends ProcessStreamConne
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String getToolsJAR() {
|
||||
File jre = new File(System.getProperty("java.home"));
|
||||
return new File(jre.getParent(), "lib" + Path.SEPARATOR + "tools.jar").getAbsolutePath();
|
||||
/**
|
||||
* Different places to look for tools jar, relative to Java home.
|
||||
*/
|
||||
private static String[] TOOLS_JAR_PATHS = {
|
||||
"../lib/tools.jar",
|
||||
"lib/tools.jar"
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a tools jar if it is needed based on current JRE version.
|
||||
*
|
||||
* @return The tools.jar, or null if none is needed.
|
||||
* @throws MissingToolsJarException If tools jar is needed but could not be found.
|
||||
*/
|
||||
protected File getToolsJAR() throws MissingToolsJarException {
|
||||
List<File> lookedIn = new ArrayList<>();
|
||||
File jhome = new File(System.getProperty("java.home"));
|
||||
// resolve(System.getenv("JAVA_HOME"), jhomes::add);
|
||||
for (String tjPath : TOOLS_JAR_PATHS) {
|
||||
File toolsJar = new File(jhome, tjPath).toPath().normalize().toFile();
|
||||
lookedIn.add(toolsJar);
|
||||
if (toolsJar.isFile()) {
|
||||
return toolsJar;
|
||||
}
|
||||
}
|
||||
throw new MissingToolsJarException(jhome, lookedIn);
|
||||
}
|
||||
|
||||
protected String getWorkingDirLocation() {
|
||||
|
||||
Reference in New Issue
Block a user