added eclipse language server plugin and feature for cloud foundry to tycho build

This commit is contained in:
Martin Lippert
2016-11-30 15:26:02 +01:00
parent e06f827d28
commit 72603ac855
10 changed files with 186 additions and 39 deletions

View File

@@ -1,6 +1,10 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Server
Bundle-SymbolicName: org.springframework.boot.ide.cloudfoundry.server
Bundle-SymbolicName: org.springframework.boot.ide.cloudfoundry.server;singleton:=true
Bundle-Version: 4.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.languageserver;bundle-version="0.1.0",
org.eclipse.jdt.launching;bundle-version="3.9.0",
org.eclipse.core.runtime;bundle-version="3.12.0"
Import-Package: org.osgi.framework

View File

@@ -1,4 +1,6 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
.,\
plugin.xml,\
servers/

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.languageserver.languageServer">
<server
class="org.springframework.boot.ide.cloudfoundry.server.CloudFoundryManifestLanguageServer"
id="org.eclipse.languageserver.languages.cloudfoundrymanifest"
label="Cloud Foundry Manifest Language Server">
</server>
<contentTypeMapping
contentType="org.springframework.boot.ide.manifest.yml"
id="org.eclipse.languageserver.languages.cloudfoundrymanifest">
</contentTypeMapping>
</extension>
</plugin>

View File

@@ -1,35 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot.ide</groupId>
<artifactId>org.springframework.boot.ide</artifactId>
<artifactId>org.springframework.boot.ide.servers</artifactId>
<version>4.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>org.springframework.boot.ide.cloudfoundry.server</artifactId>
<packaging>eclipse-plugin</packaging>
<artifactId>org.springframework.boot.ide.cloudfoundry.server</artifactId>
<packaging>eclipse-plugin</packaging>
<build>
<dependencies>
<dependency>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>vscode-manifest-yaml</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-plugin</artifactId>
<version>${tycho-version}</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>second-generate-p2-metadata</id>
<id>copy</id>
<phase>prepare-package</phase>
<goals>
<goal>p2-metadata</goal>
<goal>copy</goal>
</goals>
<phase>verify</phase>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>vscode-manifest-yaml</artifactId>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/../servers</outputDirectory>
</artifactItem>
</artifactItems>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</build>
</project>

View File

@@ -0,0 +1,83 @@
/*******************************************************************************
* Copyright (c) 2016 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.boot.ide.cloudfoundry.server;
import java.io.File;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.internal.launching.StandardVMType;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.languageserver.ProcessStreamConnectionProvider;
import org.osgi.framework.Bundle;
/**
* @author Martin Lippert
*/
@SuppressWarnings("restriction")
public class CloudFoundryManifestLanguageServer extends ProcessStreamConnectionProvider {
public CloudFoundryManifestLanguageServer() {
List<String> commands = new ArrayList<>();
commands.add(getJDKLocation());
commands.add("-jar");
commands.add(getLanguageServerJARLocation());
String workingDir = getWorkingDirLocation();
setCommands(commands);
setWorkingDirectory(workingDir);
}
protected String getJDKLocation() {
IVMInstall jdk = JavaRuntime.getDefaultVMInstall();
File javaExecutable = StandardVMType.findJavaExecutable(jdk.getInstallLocation());
return javaExecutable.getAbsolutePath();
}
protected String getLanguageServerJARLocation() {
String languageServer = "vscode-manifest-yaml-0.0.1-SNAPSHOT.jar";
Bundle bundle = Platform.getBundle(Constants.PLUGIN_ID);
File dataFile = bundle.getDataFile(languageServer);
if (!dataFile.exists()) {
try {
copyLanguageServerJAR();
}
catch (Exception e) {
e.printStackTrace();
}
}
return dataFile.getAbsolutePath();
}
protected String getWorkingDirLocation() {
// TODO: identify a reasonable working directory for the language server process
return System.getProperty("user.dir");
}
protected void copyLanguageServerJAR() throws Exception {
Bundle bundle = Platform.getBundle(Constants.PLUGIN_ID);
InputStream stream = FileLocator.openStream( bundle, new Path("servers/vscode-manifest-yaml-0.0.1-SNAPSHOT.jar"), false );
File dataFile = bundle.getDataFile("vscode-manifest-yaml-0.0.1-SNAPSHOT.jar");
Files.copy(stream, dataFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
}
}

View File

@@ -0,0 +1,20 @@
/*******************************************************************************
* Copyright (c) 2016 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.boot.ide.cloudfoundry.server;
/**
* @author Martin Lippert
*/
public class Constants {
public static final String PLUGIN_ID = "org.springframework.boot.ide.cloudfoundry.server";
}