-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild_minimum.dart
77 lines (69 loc) · 1.85 KB
/
build_minimum.dart
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
import 'dart:io';
import 'package:path/path.dart' as path;
void main() async {
const kDebugInfoDir = 'build/debug_info';
const kGradleProjectVar = 'ORG_GRADLE_PROJECT';
final debugInfoDirExists = await Directory(kDebugInfoDir).exists();
if (!debugInfoDirExists) {
await Directory(kDebugInfoDir).create(recursive: true);
}
stdout.write([
'Choose build type:',
'1. APK',
'2. Github APK',
'3. AAB',
'Select build type: ',
].join('\n'));
final buildType = stdin.readLineSync();
final environment = <String, String>{};
Process? process;
String outputDir;
switch (buildType) {
case '1' || '2':
stdout.writeln('Building APK...');
environment.addAll({
if (buildType == '2')
'${kGradleProjectVar}_KEYSTORE_PROPERTIES_FILE':
'key.github.properties'
});
process = await Process.start(
'flutter',
[
'build',
'apk',
'--split-per-abi',
'--obfuscate',
'--split-debug-info=$kDebugInfoDir'
],
environment: environment,
runInShell: true,
);
outputDir = path.join('build', 'app', 'outputs', 'flutter-apk');
case '3':
stdout.writeln('Building AAB...');
process = await Process.start(
'flutter',
[
'build',
'appbundle',
'--obfuscate',
'--split-debug-info=$kDebugInfoDir'
],
environment: environment,
runInShell: true,
);
outputDir = path.join('build', 'app', 'outputs', 'bundle', 'release');
default:
stdout.writeln('Invalid choice. The script will exit.');
exit(1);
}
stdout.addStream(process.stdout);
stderr.addStream(process.stderr);
await process.exitCode;
Process.start(
'start',
[outputDir],
environment: environment,
runInShell: true,
);
}