diff --git a/org.eclipse.wildwebdeveloper.xml/META-INF/MANIFEST.MF b/org.eclipse.wildwebdeveloper.xml/META-INF/MANIFEST.MF index 7dff209eb9..91d0edcbd2 100644 --- a/org.eclipse.wildwebdeveloper.xml/META-INF/MANIFEST.MF +++ b/org.eclipse.wildwebdeveloper.xml/META-INF/MANIFEST.MF @@ -23,7 +23,8 @@ Require-Bundle: org.eclipse.tm4e.registry;bundle-version="0.3.0", org.eclipse.text, org.eclipse.jface.text;bundle-version="3.20.100", com.google.gson, - org.eclipse.tm4e.language_pack + org.eclipse.tm4e.language_pack, + org.eclipse.lemminx.uber-jar;bundle-version="[0.29.0,1.0.0)" Bundle-ActivationPolicy: lazy Bundle-Activator: org.eclipse.wildwebdeveloper.xml.internal.Activator Export-Package: org.eclipse.wildwebdeveloper.xml;x-friends:="org.eclipse.m2e.editor.lemminx", diff --git a/org.eclipse.wildwebdeveloper.xml/build.properties b/org.eclipse.wildwebdeveloper.xml/build.properties index eca7db35da..2901665a79 100644 --- a/org.eclipse.wildwebdeveloper.xml/build.properties +++ b/org.eclipse.wildwebdeveloper.xml/build.properties @@ -4,7 +4,6 @@ bin.includes = META-INF/,\ .,\ plugin.xml,\ plugin.properties,\ - language-servers/server/,\ language-configurations/,\ grammars/,\ snippets/,\ diff --git a/org.eclipse.wildwebdeveloper.xml/pom.xml b/org.eclipse.wildwebdeveloper.xml/pom.xml index f56e3d758c..b685d3401a 100644 --- a/org.eclipse.wildwebdeveloper.xml/pom.xml +++ b/org.eclipse.wildwebdeveloper.xml/pom.xml @@ -23,34 +23,6 @@ - - org.apache.maven.plugins - maven-dependency-plugin - 3.8.1 - - - fetch-lemminx - generate-resources - - copy - - - - - org.eclipse.lemminx - org.eclipse.lemminx - - 0.29.0 - - uber - - - language-servers/server - true - - - - org.eclipse.tycho tycho-packaging-plugin @@ -62,17 +34,4 @@ - - - - lemminx-releases - https://repo.eclipse.org/content/repositories/lemminx-releases/ - - false - - - true - - - diff --git a/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/XMLLanguageServer.java b/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/XMLLanguageServer.java index db79dbe8c5..5338e9e457 100644 --- a/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/XMLLanguageServer.java +++ b/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/XMLLanguageServer.java @@ -16,7 +16,6 @@ import java.io.File; import java.io.IOException; import java.net.URI; -import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -42,8 +41,12 @@ import org.eclipse.lsp4e.server.ProcessStreamConnectionProvider; import org.eclipse.lsp4j.DidChangeConfigurationParams; import org.eclipse.wildwebdeveloper.xml.internal.ui.preferences.XMLPreferenceServerConstants; +import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; import org.osgi.framework.ServiceReference; +import org.osgi.framework.wiring.BundleWire; +import org.osgi.framework.wiring.BundleWiring; @SuppressWarnings("restriction") public class XMLLanguageServer extends ProcessStreamConnectionProvider { @@ -103,21 +106,36 @@ public XMLLanguageServer() { commands.add("-Duser.home=" + System.getProperty("user.home")); commands.add("-classpath"); try { - URL url = FileLocator - .toFileURL(getClass().getResource("/language-servers/server/org.eclipse.lemminx-uber.jar")); + Bundle lemminxBundle = getLemminxBundle(); + File file = FileLocator.getBundleFileLocation(lemminxBundle) + .orElseThrow(() -> new IllegalStateException("Can't determine lemminx file location")); List extensionJarPaths = getExtensionJarPaths(); - String uberJarPath = new java.io.File(url.getPath()).getAbsolutePath(); + String uberJarPath = file.getAbsolutePath(); jarPaths.add(uberJarPath); jarPaths.addAll(extensionJarPaths); commands.add(String.join(System.getProperty("path.separator"), jarPaths)); - commands.add("org.eclipse.lemminx.XMLServerLauncher"); + String mainClass = lemminxBundle.getHeaders().get("Main-Class"); + commands.add(mainClass); setCommands(commands); setWorkingDirectory(System.getProperty("user.dir")); - } catch (IOException e) { + } catch (RuntimeException e) { ILog.get().error(e.getMessage(), e); } } + private Bundle getLemminxBundle() { + Bundle self = FrameworkUtil.getBundle(getClass()); + BundleWiring wiring = self.adapt(BundleWiring.class); + List wires = wiring.getRequiredWires("osgi.wiring.bundle"); + for (BundleWire bundleWire : wires) { + Bundle bundle = bundleWire.getProvider().getBundle(); + if (bundle.getSymbolicName().equals("org.eclipse.lemminx.uber-jar")) { + return bundle; + } + } + throw new IllegalStateException("can't find the lemminx bundle!"); + } + private Collection getProxySettings() { Map res = new HashMap<>(); for (Entry entry : System.getProperties().entrySet()) { diff --git a/target-platform/target-platform.target b/target-platform/target-platform.target index 3cd96c43f9..fbdbd81333 100644 --- a/target-platform/target-platform.target +++ b/target-platform/target-platform.target @@ -54,5 +54,22 @@ + + + + org.eclipse.lemminx + org.eclipse.lemminx + 0.29.0 + jar + uber + + + + + lemminx-releases + https://repo.eclipse.org/content/repositories/lemminx-releases/ + + + - + \ No newline at end of file