Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 527206 - Merge LSP support into master - LSP build files
  • Loading branch information
mrennie committed Nov 30, 2017
1 parent 51af025 commit 26745ee
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 0 deletions.
47 changes: 47 additions & 0 deletions java_lsp.md
@@ -0,0 +1,47 @@
Contributing to Orion/LSP Support
=================================

Thanks for your interest in this project.

Setup instructions
------------------

1) Clone the [orion.client](https://github.com/eclipse/orion.client) Git repository checkout the `java-lsp` branch.

2) Get the lsp server from the [eclipse.jdt.ls](https://github.com/eclipse/eclipse.jdt.ls.git) Git repository and follow the `README.md` file to build it.
dfd
3) Install the compiled LSP server from the `org.eclipse.jdt.ls.product/target/repository` folder to the `org.eclipse.orion.client/modules/orionode/server` folder.

4) Inside a console where Node.js is installed, do:
- `npm install`
- start it by using: `node --debug server.js -p 8083 --w <workspace_path>`
This runs the Node.js Orion server on localhost:8083.

5) Open the browser on `http://localhost:8083`.
The Orion client with the Java™ plugin requires a Node.js Orion server that is enabled for the language server connections.
This is why for now we use a local Node.js server instead of the instance running on [orion.eclipse.org](https://orion.eclipse.org).

6) In order to help users to test the latest integration, we provide a Dockerfile and a shell script that can be used to build
a docker image that contains the latest version of the orion Node.js server with lsp support and the latest implementation of the
Java lsp server provided by the eclipse.jst.ls project. In order to do so, you need to go to the `orion.client/modules/orionode/` folder.
Then invoke the `./docker_build.sh` command. Once done, start your image using `docker run -p 8081:8081 orionlsp` and open your browser on at
`http://localhost:8081/`. You will start with an empty workspace in which you can git clone a project with Java files and test the lsp support.

Contributor License Agreement
-----------------------------

Before your contribution can be accepted by the project, you will need to create and electronically sign the
Eclipse Foundation [Contributor License Agreement](https://www.eclipse.org/legal/CLA.php) (CLA):

1. Log in to the [Eclipse projects forge](https://projects.eclipse.org/user/login/sso). You will need to
create an account with the Eclipse Foundation if you have not already done so.
2. Click on "Contributor License Agreement", and complete the form.

Be sure to use the same email address in your Eclipse account that you intend to use when you commit to Git.

Contact
-------

Contact the project developers via the project's "dev" list.

- [https://dev.eclipse.org/mailman/listinfo/orion-dev]
41 changes: 41 additions & 0 deletions modules/orionode/Dockerfile
@@ -0,0 +1,41 @@
FROM airdock/oracle-jdk

ARG JAVA_LANGUAGE_SERVER
ARG NODE_VERSION
ARG LSP_ORION_VERSION

# install java lsp server based on the latest build
RUN mkdir -p /home/java-language-server
WORKDIR /home/java-language-server
RUN curl -L http://download.eclipse.org/jdtls/snapshots/$JAVA_LANGUAGE_SERVER -o /home/java-language-server/java-server.tar.gz \
&& tar -xzvf /home/java-language-server/java-server.tar.gz \
&& rm /home/java-language-server/java-server.tar.gz

# install node 4.4.1 which is the version that matches the one used on hudson for nodejs server builds
RUN curl -SLO "http://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz" \
&& tar -xzvf "node-v$NODE_VERSION-linux-x64.tar.gz" -C /usr/local --strip-components=1 \
&& rm "node-v$NODE_VERSION-linux-x64.tar.gz" \
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs

# Create app directory
RUN mkdir -p /home/orion
WORKDIR /home/orion

# Retrieve nodejs Orion server and install it
RUN curl -SLO download.eclipse.org/orion/lsporionode/lsporionode_$LSP_ORION_VERSION.tar.gz \
&& mv lsporionode_$LSP_ORION_VERSION.tar.gz /home/orion/orionode.tar.gz \
&& tar -xzvf /home/orion/orionode.tar.gz \
&& rm /home/orion/orionode.tar.gz

# Copy the lsp server into the server folder
RUN cp -R /home/java-language-server/ /home/orion/orionode/server

WORKDIR /home/orion/orionode

# install sample project for demoing
RUN mkdir -p /home/workspace

EXPOSE 8083

WORKDIR /home/orion/orionode
CMD [ "node", "server.js", "-p", "8083", "-w","/home/workspace" ]
19 changes: 19 additions & 0 deletions modules/orionode/docker_build.sh
@@ -0,0 +1,19 @@
#!/bin/bash
set +x
set +e

LSP_ORION_VERSION=`curl -s https://hudson.eclipse.org/orion/job/lsp-orion-node/lastSuccessfulBuild/api/json | jq -r '.id'`

node getLastBuildId.js https://hudson.eclipse.org/ls/job/jdt-ls-master/lastSuccessfulBuild/api/json > lastBuildId.txt
if [ ! -s lastBuildId.txt ]
then
echo \"No java lsp server build found\"
exit 1
fi
. lastBuildId.txt
rm lastBuildId.txt

NODE_VERSION=4.4.1
echo "JAVA_LANGUAGE_SERVER=$JAVA_LANGUAGE_SERVER"
echo "LSP_ORION_VERSION=$LSP_ORION_VERSION"
docker build --build-arg JAVA_LANGUAGE_SERVER=$JAVA_LANGUAGE_SERVER --build-arg LSP_ORION_VERSION=$LSP_ORION_VERSION --build-arg NODE_VERSION=$NODE_VERSION -t orionlsp .
53 changes: 53 additions & 0 deletions modules/orionode/getLastBuildId.js
@@ -0,0 +1,53 @@
/*******************************************************************************
* @license
* Copyright (c) 2016, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0
* (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
* License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
/*eslint-env node */
var API = process.argv[2];
var http = require('https');
http.get(API, function(res) {
var statusCode = res.statusCode;
var contentType = res.headers['content-type'];

var error;
if (statusCode !== 200) {
error = new Error('Request Failed.\n' +
'Status Code: ${statusCode}');
} else if (!/^application\/json/.test(contentType)) {
error = new Error('Invalid content-type.\n' +
'Expected application/json but received ${contentType}');
}
if (error) {
// consume response data to free up memory
res.resume();
return;
}

res.setEncoding('utf8');
var rawData = '';
res.on('data', function(chunk) { rawData += chunk; });
res.on('end', function() {
try {
var parsedData = JSON.parse(rawData);
if (Array.isArray(parsedData.artifacts)) {
for (var i = 0, max = parsedData.artifacts.length; i < max; i++) {
var fileName = parsedData.artifacts[i].fileName;
if (fileName.endsWith(".tar.gz")) {
console.log('export JAVA_LANGUAGE_SERVER=' + fileName);
}
}
}
} catch (e) {
// ignore
}
});
}).on('error', /* @callback */ function(e) {
// ignore
});
28 changes: 28 additions & 0 deletions modules/orionode/lsporionode_build.sh
@@ -0,0 +1,28 @@
#!/bin/bash

function die () {
echo "Error:" "$1" >&2
exit 1
}

DOWNLOADS=/home/data/httpd/download.eclipse.org

NODEGIT_VERSION=v0.16.0
(npm install --no-optional) || die "Failed to install dependencies, consult the npm log to find out why."
cp ${DOWNLOADS}/orion/orionode/nodegit/${NODEGIT_VERSION}/linux/nodegit.node ../node_modules/nodegit/build/Release
(../node_modules/.bin/grunt ${GRUNT_TASK}) || die "Failed to minify client code."
rm -rf ../node_modules
(npm install --production --no-optional) || die "Failed to install dependencies, consult the npm log to find out why."
cp ${DOWNLOADS}/orion/orionode/nodegit/${NODEGIT_VERSION}/linux/nodegit.node ../node_modules/nodegit/build/Release
rm -rf ../node_modules/pty.js
rm -rf ../node_modules/nodegit/vendor
rm -rf ../node_modules/nodegit/build/Release/obj.target
rm -rf ../target
cd ../..

# Update build ID
sed -i "s/orion\.buildId\=/orion\.buildId\=${1}/" orionode/orion.conf
sed -i "s/var BUILD_ID \= \"unknown\"\;/var BUILD_ID \= \"${1}\"\;/" orionode/lib/version.js

tar -czf "lsporionode_$1.tar.gz" orionode/
cp "lsporionode_$1.tar.gz" ${DOWNLOADS}/orion/lsporionode/

0 comments on commit 26745ee

Please sign in to comment.