-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.js
50 lines (44 loc) · 2.07 KB
/
index.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
var shell = require('shelljs');
var _cmd = require('./src/apk-build-cmd.js');
var _exec = require('./src/apk-build-exec.js');
var SDK_ANDROID_JAR_PATH = '/Users/andy/private/tool/android/sdk/platforms/android-19/android.jar';
var SDK_MAP_JAR_PATH = '/Users/andy/private/tool/android/sdk/add-ons/addon-google_apis-google-19/libs/maps.jar';
var SDK_SDKLIB_JAR_PATH = '/Users/andy/private/tool/android/sdk/tools/lib/sdklib.jar';
/**
* 安卓客户端一键打包
*
* @param pro_path 项目路径
* @param apk_output_path apk输出路径
* @param keystore_path keystore路径
* @param keystore_pas keystore密码
* @param keystore_name keystore名称
*/
function build_exec(pro_path, apk_output_path, keystore_path, keystore_name, keystore_pas) {
// 设置全局路径
var gen_path = pro_path + '/gen';
var res_path = pro_path + '/res';
var xml_path = pro_path + '/AndroidManifest.xml';
var lib_path = pro_path + '/libs';
var ass_path = pro_path + '/assets';
var src_path = pro_path + '/src';
// 设置输出缓存文件路径
var class_path = pro_path + '/cache/classes';
var dx_path = pro_path + '/cache/dx';
var package_path = pro_path + '/cache/resources.ap_';
var unsigned_apk_path = pro_path + '/unsigned.apk';
// 移除缓存
shell.exec('rm -rf ' + pro_path + '/cache');
shell.exec('rm -rf ' + pro_path + '/*.apk');
// 初始化文件目录
shell.exec('mkdir -p ' + gen_path);
shell.exec('mkdir -p ' + class_path);
shell.exec('mkdir -p ' + dx_path);
// 开始执行脚本
_exec.aadp_exec(gen_path, res_path, xml_path, SDK_ANDROID_JAR_PATH);
_exec.compile_exec(pro_path, class_path, SDK_ANDROID_JAR_PATH, lib_path, SDK_MAP_JAR_PATH);
_exec.dex_exec(dx_path, class_path, lib_path, SDK_MAP_JAR_PATH);
_exec.package_exec(xml_path, res_path, ass_path, SDK_ANDROID_JAR_PATH, package_path);
_exec.apk_builder_exec(SDK_SDKLIB_JAR_PATH, unsigned_apk_path, package_path, dx_path + '/*.dex', src_path, lib_path);
_exec.jarsigner_exec(keystore_path, keystore_pas, keystore_name, apk_output_path, unsigned_apk_path);
}
module.exports = build_exec;