Skip to content

Commit baf99f7

Browse files
hopehadfieldrgrunber
authored andcommitted
Add build script to download language server if not found
Signed-off-by: Hope Hadfield <[email protected]>
1 parent c1ba746 commit baf99f7

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,11 @@ This assumes that you are starting on the `vscode-java` directory
8181

8282
```bash
8383
$ cd ./vscode-java
84-
$ npm run build-server
84+
$ npm run build
8585
```
86+
If the eclipse.jdt.ls directory is not found as a sibling directory (see the desired hierarchy in the previous step), a snapshot of the language server will be downloaded instead.
87+
88+
To build the server using only the local eclipse.jdt.ls repository, use `npm run build-server`.
8689

8790
**\*Optional:**
8891
You can run faster server builds during development by calling `npm run fast-build-server` script instead, this will build server binaries that are required by your host OS only. You can also use `npm run watch-server` which will build and place them on the extension for Java changes. These commands run Maven in offline mode, so you might need to run `build-server` at least once, to fetch all the dependencies.

gulpfile.js

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const server_dir = '../eclipse.jdt.ls';
1313
const originalTestFolder = path.join(__dirname, 'test', 'resources', 'projects', 'maven', 'salut');
1414
const tempTestFolder = path.join(__dirname, 'test-temp');
1515
const testSettings = path.join(tempTestFolder, '.vscode', 'settings.json');
16+
const JDT_LS_SNAPSHOT_URL = "http://download.eclipse.org/jdtls/snapshots/jdt-language-server-latest.tar.gz"
1617
//...
1718

1819
gulp.task('clean_jre', function (done) {
@@ -145,19 +146,23 @@ gulp.task('download_lombok', async function (done) {
145146
});
146147

147148
gulp.task('download_server', function (done) {
148-
fse.removeSync('./server');
149-
download("http://download.eclipse.org/jdtls/snapshots/jdt-language-server-latest.tar.gz")
150-
.pipe(decompress())
151-
.pipe(gulp.dest('./server'));
149+
download_server_fn();
152150
done();
153151
});
154152

155153
gulp.task('build_server', function (done) {
156-
fse.removeSync('./server');
157-
cp.execSync(mvnw() + ' -Pserver-distro clean package -Declipse.jdt.ls.skipGradleChecksums', { cwd: server_dir, stdio: [0, 1, 2] });
158-
gulp.src(server_dir + '/org.eclipse.jdt.ls.product/distro/*.tar.gz')
159-
.pipe(decompress())
160-
.pipe(gulp.dest('./server'));
154+
build_server_fn();
155+
done();
156+
});
157+
158+
gulp.task('build_or_download', function (done) {
159+
if (!fse.existsSync(server_dir)) {
160+
console.log('NOTE: eclipse.jdt.ls is not found as a sibling directory, downloading the latest snapshot of the Eclipse JDT Language Server...');
161+
download_server_fn();
162+
}
163+
else {
164+
build_server_fn();
165+
}
161166
done();
162167
});
163168

@@ -244,3 +249,18 @@ function prependZero(num) {
244249
}
245250
return `${num < 10 ? "0" : ""}${num}`;
246251
}
252+
253+
function download_server_fn(){
254+
fse.removeSync('./server');
255+
download(JDT_LS_SNAPSHOT_URL)
256+
.pipe(decompress())
257+
.pipe(gulp.dest('./server'));
258+
}
259+
260+
function build_server_fn(){
261+
fse.removeSync('./server');
262+
cp.execSync(mvnw() + ' -Pserver-distro clean package -Declipse.jdt.ls.skipGradleChecksums', { cwd: server_dir, stdio: [0, 1, 2] });
263+
gulp.src(server_dir + '/org.eclipse.jdt.ls.product/distro/*.tar.gz')
264+
.pipe(decompress())
265+
.pipe(gulp.dest('./server'));
266+
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,7 @@
14311431
"pretest": "npm run compile",
14321432
"test": "node ./out/test/runtest.js",
14331433
"build-server": "./node_modules/.bin/gulp build_server",
1434+
"build": "./node_modules/.bin/gulp build_or_download",
14341435
"fast-build-server": "./node_modules/.bin/gulp dev_server",
14351436
"watch-server": "./node_modules/.bin/gulp watch_server",
14361437
"eslint": "eslint --ignore-path .eslintignore --ext .js,.ts,.tsx ."

0 commit comments

Comments
 (0)