-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathbuildJdtlsExt.js
More file actions
44 lines (36 loc) · 1.64 KB
/
Copy pathbuildJdtlsExt.js
File metadata and controls
44 lines (36 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
const cp = require('child_process');
const fse = require('fs-extra');
const path = require('path');
const server_dir = path.resolve('jdtls.ext');
// Set JVM options to increase XML entity size limits
// JDK 24 contains changes to JAXP limits, see: https://bugs.openjdk.org/browse/JDK-8343022
const jvmOptions = [
'-Djdk.xml.maxGeneralEntitySizeLimit=0',
'-Djdk.xml.totalEntitySizeLimit=0'
].join(' ');
// Set MAVEN_OPTS environment variable with JVM options
const env = { ...process.env };
env.MAVEN_OPTS = env.MAVEN_OPTS ? env.MAVEN_OPTS + ' ' + jvmOptions : jvmOptions;
// `eclipse.p2.mirrors=false` stops p2 from following download.eclipse.org's mirror
// redirect, which hands out a different third party host per request and makes the
// set of addresses the build contacts impossible to express as an allow list.
const mvnCommand = `${mvnw()} clean package -Declipse.p2.mirrors=false`;
cp.execSync(mvnCommand, {cwd:server_dir, stdio:[0,1,2], env: env} );
copy(path.join(server_dir, 'com.microsoft.jdtls.ext.core/target'), path.resolve('server'), (file) => {
return /^com.microsoft.jdtls.ext.core.*.jar$/.test(file);
});
function copy(sourceFolder, targetFolder, fileFilter) {
const jars = fse.readdirSync(sourceFolder).filter(file => fileFilter(file));
fse.ensureDirSync(targetFolder);
for (const jar of jars) {
fse.copyFileSync(path.join(sourceFolder, jar), path.join(targetFolder, path.basename(jar)));
}
}
function isWin() {
return /^win/.test(process.platform);
}
function mvnw() {
return isWin()?"mvnw.cmd":"./mvnw";
}