-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-backend.js
48 lines (42 loc) · 1.21 KB
/
build-backend.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
const exec = require('child_process').exec;
const fs = require('fs-extra');
const backendJarSource = 'target/backend.jar';
const backendJarDestination = 'src/main/resources/backend.jar';
console.log('Building backend jar...');
exec('mvn clean package', function(error, stdout, stderr) {
if (error != null) {
console.log(stdout);
console.error(stderr);
process.exit(error.code || 1);
}
try {
fs.removeSync(backendJarDestination);
fs.copySync(backendJarSource, backendJarDestination);
exec('mvn clean', function(error, stdout, stderr) {
if (error != null) {
console.log(stdout);
console.error(stderr);
process.exit(error.code || 1);
}
// Attempt to remove 'out' directory, with retries
let tries = 3;
let removeOutErr = null;
while (tries-- > 0) {
try {
fs.removeSync('out');
removeOutErr = null;
} catch (error) {
removeOutErr = error;
}
}
if (removeOutErr != null) {
console.error(error.message);
process.exit(1);
}
console.log('Done building backend jar');
});
} catch (error) {
console.error(error.message);
process.exit(1);
}
});