From bc951ee13d900c784ec017b18bee56cada9f080a Mon Sep 17 00:00:00 2001 From: Poytr1 Date: Thu, 14 Feb 2019 20:12:45 +0800 Subject: [PATCH 1/2] [Code] Fix Java launcher --- x-pack/package.json | 1 + .../plugins/code/server/lsp/java_launcher.ts | 26 +++++++++---------- yarn.lock | 9 +++++-- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/x-pack/package.json b/x-pack/package.json index 4001fb14db916..124a3e4906d72 100644 --- a/x-pack/package.json +++ b/x-pack/package.json @@ -176,6 +176,7 @@ "bluebird": "3.5.3", "boom": "^7.2.0", "brace": "0.11.1", + "chmodr": "^1.2.0", "chroma-js": "^1.3.6", "classnames": "2.2.5", "concat-stream": "1.5.1", diff --git a/x-pack/plugins/code/server/lsp/java_launcher.ts b/x-pack/plugins/code/server/lsp/java_launcher.ts index 11b5a9c0da2ef..fcc806e91f697 100644 --- a/x-pack/plugins/code/server/lsp/java_launcher.ts +++ b/x-pack/plugins/code/server/lsp/java_launcher.ts @@ -5,6 +5,7 @@ */ import { spawn } from 'child_process'; +import chmodr from 'chmodr'; import getPort from 'get-port'; import * as glob from 'glob'; import { platform as getOsPlatform } from 'os'; @@ -89,34 +90,33 @@ export class JavaLauncher implements ILanguageServerLauncher { if (!JDKFound.length) { log.error('cannot find executable JDK'); } - return JDKFound; + return path.resolve(installationPath, JDKFound[0]); } - let config = './config_mac/'; - let javaPath = ''; + let config = 'config_mac'; + let javaPath = 'java'; let javaHomePath = ''; // detect platform switch (getOsPlatform()) { case 'darwin': javaHomePath = `${findJDK('osx')}/Contents/Home`; - javaPath = `${javaHomePath}/bin/java`; + javaPath = path.resolve(`${javaHomePath}`, 'bin', 'java'); break; case 'win32': javaHomePath = `${findJDK('windows')}`; - javaPath = `${javaHomePath}/bin/java.exe`; - config = './config_win/'; + javaPath = path.resolve(`${javaHomePath}`, 'bin', 'java.exe'); + config = 'config_win'; break; case 'linux': javaHomePath = `${findJDK('linux')}`; - javaPath = `${javaHomePath}/bin/java`; - config = './config_linux/'; + javaPath = path.resolve(`${javaHomePath}`, 'bin', 'java'); + config = 'config_linux'; break; default: log.error('Unable to find platform for this os'); } - process.env.CLIENT_HOST = '127.0.0.1'; - process.env.CLIENT_PORT = port.toString(); - process.env.JAVA_HOME = javaHomePath; + + chmodr.sync(path.dirname(javaPath), 0o755); const p = spawn( javaPath, @@ -130,14 +130,14 @@ export class JavaLauncher implements ILanguageServerLauncher { '-jar', path.resolve(installationPath, launchersFound[0]), '-configuration', - path.resolve(installationPath, config), + path.resolve(installationPath, './repository', config), '-data', this.options.jdtWorkspacePath, ], { detached: false, stdio: 'pipe', - env: process.env, + env: { CLIENT_HOST: '127.0.0.1', CLIENT_PORT: port.toString(), JAVA_HOME: javaHomePath }, } ); p.stdout.on('data', data => { diff --git a/yarn.lock b/yarn.lock index 359c1587ed4ae..e052f35574e2c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5378,6 +5378,11 @@ cheerio@^1.0.0-rc.2: lodash "^4.15.0" parse5 "^3.0.1" +chmodr@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/chmodr/-/chmodr-1.2.0.tgz#720e96caa09b7f1cdbb01529b7d0ab6bc5e118b9" + integrity sha512-Y5uI7Iq/Az6HgJEL6pdw7THVd7jbVOTPwsmcPOBjQL8e3N+pz872kzK5QxYGEy21iRys+iHWV0UZQXDFJo1hyA== + chokidar@1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.6.0.tgz#90c32ad4802901d7713de532dc284e96a63ad058" @@ -12779,7 +12784,7 @@ javascript-typescript-langserver@^2.11.2: rxjs "^5.5.0" semaphore-async-await "^1.5.1" string-similarity "^2.0.0" - typescript "~3.1.1" + typescript "~3.0.3" vscode-jsonrpc "^4.0.0" vscode-languageserver "^5.0.0" vscode-languageserver-types "^3.0.3" @@ -22334,7 +22339,7 @@ typescript-fsa@^2.0.0, typescript-fsa@^2.5.0: resolved "https://registry.yarnpkg.com/typescript-fsa/-/typescript-fsa-2.5.0.tgz#1baec01b5e8f5f34c322679d1327016e9e294faf" integrity sha1-G67AG16PXzTDImedEycBbp4pT68= -typescript@^3.0.3: +typescript@^3.0.3, typescript@~3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.0.3.tgz#4853b3e275ecdaa27f78fda46dc273a7eb7fc1c8" integrity sha512-kk80vLW9iGtjMnIv11qyxLqZm20UklzuR2tL0QAnDIygIUIemcZMxlMWudl9OOt76H3ntVzcTiddQ1/pAAJMYg== From 00c38275af3715745db7bff2ec80294593e235b3 Mon Sep 17 00:00:00 2001 From: Poytr1 Date: Thu, 14 Feb 2019 21:08:56 +0800 Subject: [PATCH 2/2] [Code] Ignore changes of java_langserver during development mode --- src/cli/cluster/cluster_manager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cli/cluster/cluster_manager.js b/src/cli/cluster/cluster_manager.js index 95b92eb90ed1c..ebcc4cd5826b7 100644 --- a/src/cli/cluster/cluster_manager.js +++ b/src/cli/cluster/cluster_manager.js @@ -181,6 +181,7 @@ export default class ClusterManager { /[\\\/](\..*|node_modules|bower_components|public|__[a-z0-9_]+__|coverage)[\\\/]/, /\.test\.js$/, ...extraIgnores, + 'plugins/java_languageserver' ], });