Add warning message in Eclipse for missing tools.jar on boot-java ls

This commit is contained in:
Kris De Volder
2018-01-26 15:33:15 -08:00
parent 7c84dab418
commit c07d97386f
3 changed files with 100 additions and 5 deletions

View File

@@ -0,0 +1,50 @@
/*******************************************************************************
* Copyright (c) 2018 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.tooling.boot.java.ls;
import java.io.File;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
import org.springframework.tooling.ls.eclipse.commons.STS4LanguageServerProcessStreamConnector.MissingToolsJarException;
public class MissingToolsJarWarning {
private static boolean missingToolsJarWarningIssued = false;
public static void show(MissingToolsJarException e) {
Display.getDefault().asyncExec(() -> {
//Don't warn more than once per Eclipse session.
if (!missingToolsJarWarningIssued) {
missingToolsJarWarningIssued = true;
StringBuilder lookedIn = new StringBuilder();
for (File file : e.lookedIn) {
lookedIn.append(" ");
lookedIn.append(file);
lookedIn.append("\n");
}
MessageDialog.openWarning(null, "Missing 'tools.jar'",
"Could not find 'tools.jar' in the active JRE.\n\n"+
"Spring Boot Live hovers will not work without it.\n\n" +
"The JRE you are running Eclipse with is:\n "+e.javaHome+"\n\n" +
"Where we looked for 'tools.jar':\n" +
lookedIn
);
}
});
}
}

View File

@@ -39,7 +39,16 @@ public class SpringBootJavaLanguageServer extends STS4LanguageServerProcessStrea
commands.add("-Dlsp.completions.indentation.enable=true");
commands.add("-Xmx1024m");
commands.add("-cp");
commands.add(getToolsJAR() + File.pathSeparator + getLanguageServerJARLocation());
String classpath = getLanguageServerJARLocation();
try {
File toolsJar = getToolsJAR();
if (toolsJar!=null) {
classpath = toolsJar + File.pathSeparator + classpath;
}
} catch (MissingToolsJarException e) {
MissingToolsJarWarning.show(e);
}
commands.add(classpath);
commands.add("org.springframework.boot.loader.JarLauncher");
String workingDir = getWorkingDirLocation();