-
Notifications
You must be signed in to change notification settings - Fork 14
/
gulpfile.js
87 lines (77 loc) · 3.37 KB
/
gulpfile.js
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
* Copyright 2019 Red Hat, Inc. 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
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const gulp = require('gulp');
const rename = require('gulp-rename');
const cp = require('child_process');
const fse = require('fs-extra');
const microprofileServerName = 'org.eclipse.lsp4mp.ls-uber.jar';
const microprofileServerDir = '../lsp4mp/microprofile.ls/org.eclipse.lsp4mp.ls';
const microprofileExtensionDir = '../lsp4mp/microprofile.jdt';
const microprofileExtension = 'org.eclipse.lsp4mp.jdt.core';
const microprofileSite = 'org.eclipse.lsp4mp.jdt.site';
gulp.task('buildServer', (done) => {
cp.execSync(mvnw() + ' clean install -B -DskipTests', { cwd: microprofileServerDir , stdio: 'inherit' });
gulp.src(microprofileServerDir + '/target/' + microprofileServerName, { encoding: false })
.pipe(gulp.dest('./server'));
done();
});
gulp.task('buildExtension', (done) => {
cp.execSync(mvnw() + ' clean verify -B -DskipTests', { cwd: microprofileExtensionDir, stdio: 'inherit' });
gulp.src(microprofileExtensionDir + '/' + microprofileExtension + '/target/' + microprofileExtension + '-!(*sources).jar', { encoding: false })
.pipe(rename(microprofileExtension + '.jar'))
.pipe(gulp.dest('./jars'));
gulp.src(microprofileExtensionDir + '/' + microprofileSite + '/target/repository/plugins/wrapped*.jar', { encoding: false })
.pipe(rename(function (path, _file) {
const patt = /wrapped\.([^_]+).*/;
const result = path.basename.match(patt);
path.basename = result[1];
}))
.pipe(gulp.dest('./jars'));
gulp.src(microprofileExtensionDir + '/' + microprofileSite + '/target/repository/plugins/org.jboss.logging*.jar', { encoding: false })
.pipe(rename(function (path, _file) {
const patt = /([^_]+).*/;
const result = path.basename.match(patt);
path.basename = result[1];
}))
.pipe(gulp.dest('./jars'));
done();
});
gulp.task('build', gulp.series('buildServer', 'buildExtension'));
gulp.task('prepare_pre_release', function (done) {
const json = JSON.parse(fse.readFileSync("./package.json").toString());
const stableVersion = json.version.match(/(\d+)\.(\d+)\.(\d+)/);
const major = stableVersion[1];
const minor = stableVersion[2];
const date = new Date();
const month = date.getMonth() + 1;
const day = date.getDate();
const hours = date.getHours();
const patch = `${date.getFullYear()}${prependZero(month)}${prependZero(day)}${prependZero(hours)}`;
const insiderPackageJson = Object.assign(json, {
version: `${major}.${minor}.${patch}`,
});
fse.writeFileSync("./package.json", JSON.stringify(insiderPackageJson, null, 2));
done();
});
function mvnw() {
return isWin() ? 'mvnw.cmd' : './mvnw';
}
function isWin() {
return /^win/.test(process.platform);
}
function prependZero(number) {
if (number > 99) {
throw "Unexpected value to prepend with zero";
}
return `${number < 10 ? "0" : ""}${number}`;
}