PT #157682497: Build fat jar instead of downloading for theia extensions

This commit is contained in:
BoykoAlex
2018-05-17 19:59:45 -04:00
parent 984eafc2c0
commit 09c170730a
25 changed files with 9606 additions and 1124 deletions

View File

@@ -4,4 +4,4 @@ lib
*.log
*-app/*
!*-app/package.json
/**/server
/**/jars

View File

@@ -15,12 +15,12 @@ Install yarn.
npm install -g yarn
## Install dependencies
## Install dependencies and server JARs
Install dependencies and compile the code.
yarn
./build.sh
Note: it is also running `yarn rebuild:browser` and `yarn rebuild:electron`, thus one could navigate to the proper folder and launch it
## Running the browser example

View File

@@ -0,0 +1,17 @@
#!/bin/bash
set -e
workdir=`pwd`/cf-manifest-yaml
cd ${workdir}
# Use maven to build fat jar of the language server
cd ../../../headless-services/manifest-yaml-language-server
./build.sh
rm -fr ${workdir}/jars
mkdir -p ${workdir}/jars
cp target/*.jar ${workdir}/jars
cd ${workdir}/..
yarn

View File

@@ -6,7 +6,8 @@
"version": "0.0.1",
"files": [
"lib",
"src"
"src",
"jars"
],
"dependencies": {
"@theia/core": "latest",
@@ -18,12 +19,10 @@
},
"devDependencies": {
"rimraf": "latest",
"typescript": "latest",
"download": "^6.2.5"
"typescript": "latest"
},
"scripts": {
"prepare": "yarn run clean && yarn run download && yarn run build",
"download": "node script.js",
"prepare": "yarn run clean && yarn run build",
"clean": "rimraf lib",
"build": "tsc",
"watch": "tsc -w"

View File

@@ -1,3 +0,0 @@
{
"jarUrl": "https://s3-us-west-1.amazonaws.com/s3-test.spring.io/sts4/fatjars/snapshots/manifest-yaml-language-server-0.2.1-201804171251.jar"
}

View File

@@ -1,34 +0,0 @@
const fs = require('fs');
const path = require('path');
const url = require('url');
const glob = require('glob');
const download = require('download');
const PROPERTIES = require('./properties.json');
let fileExists = function(path) {
return new Promise((resolve, reject) => {
fs.access(path, fs.R_OK, error => {
resolve(!error || error.code !== 'ENOENT');
})
});
};
const serverHome = path.join(__dirname, 'server');
const filePaths = glob.sync('manifest-yaml-language-server*.jar', { cwd: serverHome });
if (filePaths.length === 0) {
const serverDownloadUrl = PROPERTIES.jarUrl;
const fileName = path.basename(url.parse(serverDownloadUrl).pathname);
const localFileName = path.join(serverHome, fileName.startsWith('manifest-yaml-language-server') ? fileName : 'manifest-yaml-language-server.jar');
console.log(`Downloading ${serverDownloadUrl} to ${localFileName}`);
fileExists(serverHome)
.then(doesExist => { if (!doesExist) fs.mkdir(serverHome) })
.then(() => download(serverDownloadUrl))
.then(data => fs.writeFileSync(localFileName, data))
.then(() => fileExists(localFileName))
.then(doesExist => { if (!doesExist) throw Error(`Failed to install the ${this.getServerName()} language server`); })
.then(() => console.log(`Successfully downloaded ${serverDownloadUrl}`));
}

View File

@@ -1,17 +1,10 @@
/*
* Copyright (C) 2017 TypeFox and others.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
import * as path from 'path';
import * as glob from 'glob';
import { injectable } from "inversify";
import { injectable } from 'inversify';
// import { DEBUG_MODE } from '@theia/core/lib/node';
import { IConnection, BaseLanguageServerContribution } from "@theia/languages/lib/node";
import { IConnection, BaseLanguageServerContribution } from '@theia/languages/lib/node';
import { CF_MANIFEST_YAML_LANGUAGE_ID, CF_MANIFEST_YAML_LANGUAGE_NAME } from '../common';
import {findJdk, findJvm, JVM} from '@pivotal-tools/jvm-launch-utils';
import { findJvm } from '@pivotal-tools/jvm-launch-utils';
@injectable()
@@ -20,32 +13,15 @@ export class CfManifestYamlContribution extends BaseLanguageServerContribution {
readonly id = CF_MANIFEST_YAML_LANGUAGE_ID;
readonly name = CF_MANIFEST_YAML_LANGUAGE_NAME;
preferJdk(): boolean {
return false;
}
findJvm(): Promise<JVM | null> {
return this.preferJdk() ? findJdk() : findJvm();
}
launchVmArgs(jvm: JVM): string[] {
return [
'-Dsts.lsp.client=theia',
'-Dlsp.completions.indentation.enable=true',
'-Dlsp.yaml.completions.errors.disable=true',
'-Dorg.slf4j.simpleLogger.logFile=cf-manifest-yaml.log'
];
}
start(clientConnection: IConnection): void {
const serverPath = path.resolve(__dirname, '../../server');
const serverPath = path.resolve(__dirname, '../../jars');
const jarPaths = glob.sync('manifest-yaml-language-server*.jar', { cwd: serverPath });
if (jarPaths.length === 0) {
throw new Error('The CF Manifest YAML server launcher is not found.');
}
const jarPath = path.resolve(serverPath, jarPaths[0]);
this.findJvm()
findJvm()
.catch(error => {
throw new Error('Error trying to find JVM');
})
@@ -53,24 +29,25 @@ export class CfManifestYamlContribution extends BaseLanguageServerContribution {
if (!jvm) {
throw new Error("Couldn't locate java in $JAVA_HOME or $PATH");
}
let version = jvm.getMajorVersion();
if (version<1) {
throw new Error(
'No compatible Java Runtime Environment found. The Java Runtime Environment is either below version "1.8" or is missing from the system'
);
}
this.startSocketServer().then(server => {
const socket = this.accept(server);
// this.logInfo('logs at ' + path.resolve(workspacePath, '.metadata', '.log'));
const env = Object.create(process.env);
env.CLIENT_HOST = server.address().address;
env.CLIENT_PORT = server.address().port;
const addressInfo = server.address();
if (typeof addressInfo === 'string') {
throw new Error(`Address info was string ${addressInfo}`);
}
env.CLIENT_HOST = addressInfo.address;
env.CLIENT_PORT = addressInfo.port;
const command = jvm.getJavaExecutable();
const args = this.launchVmArgs(jvm);
args.push(`-Dserver.port=${env.CLIENT_PORT}`);
const args = [
'-Dsts.lsp.client=theia',
'-Dlsp.completions.indentation.enable=true',
'-Dlsp.yaml.completions.errors.disable=true',
'-Dorg.slf4j.simpleLogger.logFile=cf-manifest-yaml.log',
`-Dserver.port=${env.CLIENT_PORT}`
];
// if (DEBUG_MODE) {
args.push(

View File

@@ -1,34 +0,0 @@
const fs = require('fs');
const path = require('path');
const download = require('download');
const PROPERTIES = require('./properties.json');
let fileExists = function(path) {
return new Promise((resolve, reject) => {
fs.access(path, fs.R_OK, error => {
resolve(!error || error.code !== 'ENOENT');
})
});
};
const serverDownloadUrl = PROPERTIES.jarUrl;
const serverHome = path.join(__dirname, 'server');
const localFileName = path.join(serverHome, 'cf-manifest-language-server.jar');
fileExists(localFileName).then(exists => {
if (!exists) {
console.log(`Downloading ${serverDownloadUrl} to ${localFileName}`);
fileExists(serverHome)
.then(doesExist => { if (!doesExist) fs.mkdir(serverHome) })
.then(() => download(serverDownloadUrl))
.then(data => fs.writeFileSync(localFileName, data))
.then(() => fileExists(localFileName))
.then(doesExist => { if (!doesExist) throw Error(`Failed to install the ${this.getServerName()} language server`) })
.then(() => console.log(`Successfully downloaded ${serverDownloadUrl}`));
}
});

File diff suppressed because it is too large Load Diff

View File

@@ -4,5 +4,5 @@ lib
*.log
*-app/*
!*-app/package.json
/**/server
/**/jars

View File

@@ -16,11 +16,11 @@ Install yarn.
npm install -g yarn
## Install dependencies
## Install dependencies and server JARs
Install dependencies and compile the code.
yarn
./build.sh
Note: it is also running `yarn rebuild:browser` and `yarn rebuild:electron`, thus one could navigate to the proper folder and launch it

View File

@@ -0,0 +1,17 @@
#!/bin/bash
set -e
workdir=`pwd`/concourse
cd ${workdir}
# Use maven to build fat jar of the language server
cd ../../../headless-services/concourse-language-server
./build.sh
rm -fr ${workdir}/jars
mkdir -p ${workdir}/jars
cp target/*.jar ${workdir}/jars
cd ${workdir}/..
yarn

View File

@@ -6,7 +6,8 @@
"version": "0.0.0",
"files": [
"lib",
"src"
"src",
"jars"
],
"dependencies": {
"@theia/core": "latest",
@@ -17,12 +18,10 @@
},
"devDependencies": {
"rimraf": "latest",
"typescript": "latest",
"download": "^6.2.5"
"typescript": "latest"
},
"scripts": {
"prepare": "yarn run clean && yarn run download && yarn run build",
"download": "node script.js",
"prepare": "yarn run clean && yarn run build",
"clean": "rimraf lib",
"build": "tsc",
"watch": "tsc -w"

View File

@@ -1,3 +0,0 @@
{
"jarUrl": "https://s3.amazonaws.com/dist.springsource.com/release/STS4/fatjars/concourse-language-server-0.2.1-201805111942.jar"
}

View File

@@ -1,34 +0,0 @@
const fs = require('fs');
const path = require('path');
const url = require('url');
const glob = require('glob');
const download = require('download');
const PROPERTIES = require('./properties.json');
let fileExists = function(path) {
return new Promise((resolve, reject) => {
fs.access(path, fs.R_OK, error => {
resolve(!error || error.code !== 'ENOENT');
})
});
};
const serverHome = path.join(__dirname, 'server');
const filePaths = glob.sync('concourse-language-server*.jar', { cwd: serverHome });
if (filePaths.length === 0) {
const serverDownloadUrl = PROPERTIES.jarUrl;
const fileName = path.basename(url.parse(serverDownloadUrl).pathname);
const localFileName = path.join(serverHome, fileName.startsWith('concourse-language-server') ? fileName : 'concourse-language-server.jar');
console.log(`Downloading ${serverDownloadUrl} to ${localFileName}`);
fileExists(serverHome)
.then(doesExist => { if (!doesExist) fs.mkdir(serverHome) })
.then(() => download(serverDownloadUrl))
.then(data => fs.writeFileSync(localFileName, data))
.then(() => fileExists(localFileName))
.then(doesExist => { if (!doesExist) throw Error(`Failed to install the ${this.getServerName()} language server`); })
.then(() => console.log(`Successfully downloaded ${serverDownloadUrl}`));
}

View File

@@ -21,7 +21,7 @@ export class ConcourseLanguageContribution extends BaseLanguageServerContributio
readonly name = CONCOURSE_SERVER_NAME;
start(clientConnection: IConnection): void {
const serverPath = path.resolve(__dirname, '../../server');
const serverPath = path.resolve(__dirname, '../../jars');
const jarPaths = glob.sync('concourse-language-server*.jar', { cwd: serverPath });
if (jarPaths.length === 0) {
throw new Error('The Concourse YAML server launcher is not found.');

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
node_modules
.browser_modules
lib
server
jars
*.log
*-app/*
!*-app/package.json

View File

@@ -16,11 +16,11 @@ Install yarn.
npm install -g yarn
## Install dependencies
## Install dependencies and server JARs
Install dependencies and compile the code.
yarn
./build.sh
Note: it is also running `yarn rebuild:browser` and `yarn rebuild:electron`, thus one could navigate to the proper folder and launch it

View File

@@ -0,0 +1,17 @@
#!/bin/bash
set -e
workdir=`pwd`/spring-boot
cd ${workdir}
# Use maven to build fat jar of the language server
cd ../../../headless-services/spring-boot-language-server
./build.sh
rm -fr ${workdir}/jars
mkdir -p ${workdir}/jars
cp target/*.jar ${workdir}/jars
cd ${workdir}/..
yarn

View File

@@ -7,6 +7,7 @@
"files": [
"lib",
"src",
"jars",
"images"
],
"dependencies": {
@@ -22,12 +23,10 @@
},
"devDependencies": {
"rimraf": "latest",
"typescript": "latest",
"download": "^6.2.5"
"typescript": "latest"
},
"scripts": {
"prepare": "yarn run clean && yarn run download && yarn run build",
"download": "node script.js",
"prepare": "yarn run clean && yarn run build",
"clean": "rimraf lib",
"build": "tsc",
"watch": "tsc -w"

View File

@@ -1,3 +0,0 @@
{
"jarUrl": "https://s3-us-west-1.amazonaws.com/s3-test.spring.io/sts4/fatjars/snapshots/spring-boot-language-server-0.2.1-201805050150.jar"
}

View File

@@ -1,34 +0,0 @@
const fs = require('fs');
const path = require('path');
const url = require('url');
const glob = require('glob');
const download = require('download');
const PROPERTIES = require('./properties.json');
let fileExists = function(path) {
return new Promise((resolve, reject) => {
fs.access(path, fs.R_OK, error => {
resolve(!error || error.code !== 'ENOENT');
})
});
};
const serverHome = path.join(__dirname, 'server');
const filePaths = glob.sync('spring-boot-language-server*.jar', { cwd: serverHome });
if (filePaths.length === 0) {
const serverDownloadUrl = PROPERTIES.jarUrl;
const fileName = path.basename(url.parse(serverDownloadUrl).pathname);
const localFileName = path.join(serverHome, fileName.startsWith('spring-boot-language-server') ? fileName : 'spring-boot-language-server.jar');
console.log(`Downloading ${serverDownloadUrl} to ${localFileName}`);
fileExists(serverHome)
.then(doesExist => { if (!doesExist) fs.mkdir(serverHome) })
.then(() => download(serverDownloadUrl))
.then(data => fs.writeFileSync(localFileName, data))
.then(() => fileExists(localFileName))
.then(doesExist => { if (!doesExist) throw Error(`Failed to install the ${this.getServerName()} language server`); })
.then(() => console.log(`Successfully downloaded ${serverDownloadUrl}`));
}

View File

@@ -14,7 +14,7 @@ export class SpringBootLsContribution extends BaseLanguageServerContribution {
readonly name = SPRING_BOOT_SERVER_NAME;
start(clientConnection: IConnection): void {
const serverPath = path.resolve(__dirname, '../../server');
const serverPath = path.resolve(__dirname, '../../jars');
const jarPaths = glob.sync('spring-boot-language-server*.jar', { cwd: serverPath });
if (jarPaths.length === 0) {
throw new Error('The Spring Boot server launcher is not found.');
@@ -49,8 +49,12 @@ export class SpringBootLsContribution extends BaseLanguageServerContribution {
// this.logInfo('logs at ' + path.resolve(workspacePath, '.metadata', '.log'));
const env = Object.create(process.env);
env.CLIENT_HOST = server.address().address;
env.CLIENT_PORT = server.address().port;
const addressInfo = server.address();
if (typeof addressInfo === 'string') {
throw new Error(`Address info was string ${addressInfo}`);
}
env.CLIENT_HOST = addressInfo.address;
env.CLIENT_PORT = addressInfo.port;
const command = jvm.getJavaExecutable();
const args = [
'-Dsts.lsp.client=theia',

File diff suppressed because it is too large Load Diff