-
Notifications
You must be signed in to change notification settings - Fork 8
/
gulpfile.js
63 lines (56 loc) · 2.28 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
// Gulpfile for Adapt It Mobile builds
var gulp = require("gulp"),
fs = require("fs"),
cp = require('child_process'),
cordova = require("cordova-lib").cordova;
// prep the Android platform -- either add it or clean it
gulp.task("prep-android-dir", function (done) {
var path = "./platforms/android";
if (!fs.existsSync(path)) {
process.stdout.write('Android dir not detected -- creating platform android\n');
var cmd = cp.spawn('cordova', ["platform", "add", "android"], {stdio: 'inherit'}).on('exit', done);
} else {
process.stdout.write('cleaning platform android\n');
var cmd = cp.spawn('cordova', ["clean", "android"], {stdio: 'inherit'}).on('exit', done);
}
});
// build Android
gulp.task("build-android", function (done) {
cordova.build({
"platforms": ["android"],
"options": {
argv: ["--release", "--verbose", "--buildConfig=build.json", "--gradleArg=--no-daemon"]
}
}, done());
});
// prep the iOS platform -- either add it or clean it
gulp.task("prep-ios-dir", function (done) {
var path = "./platforms/ios";
if (!fs.existsSync(path)) {
process.stdout.write('ios dir not detected -- creating platform ios\n');
var cmd = cp.spawn('cordova', ["platform", "add", "ios@latest"], {stdio: 'inherit'}).on('exit', done);
} else {
process.stdout.write('cleaning platform ios\n');
var cmd = cp.spawn('cordova', ["clean", "ios"], {stdio: 'inherit'}).on('exit', done);
// cordova.clean("ios", {argv: "--verbose"});
// done();
}
});
// build iOS
gulp.task("build-ios", function (done) {
cordova.build({
"platforms": ["ios"],
"options": {
argv: ["--release", "--verbose", "--buildConfig=build.json", "--device"]
}
}, done());
});
// prep both Android and iOS
gulp.task("prep", gulp.parallel("prep-android-dir", "prep-ios-dir"));
// build both Android and iOS
gulp.task("build", gulp.parallel("build-android", "build-ios"));
// default (gulp) - just build Android for the CI build
gulp.task("default", gulp.series("build-android"), function () {
// Copy results to bin folder
gulp.src("platforms/android/app/build/output/apk/release/*.apk").pipe(gulp.dest("bin/release/android")); // Gradle build
});