Skip to content
This repository was archived by the owner on Apr 3, 2020. It is now read-only.

Commit 192d693

Browse files
committed
Merge pull request #163 from fujunwei/xwalk-url
Add the option of "--xwalk-apk-url" when creating Cordova project
2 parents 2160173 + c684407 commit 192d693

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

bin/create

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,17 @@ if (args['--help'] || args._.length === 0) {
3030
console.log(' <template_path>: Path to a custom application template to use');
3131
console.log(' --shared will use the CordovaLib project directly instead of making a copy.');
3232
console.log(' --xwalk-shared-library will use Crosswalk shared mode to package the project that without xwalk so library.');
33+
console.log(' --xwalk-apk-url configure the download URL of the Crosswalk runtime library.');
3334
process.exit(1);
3435
}
35-
if (args['--shared'] && args['--xwalk-shared-library']) {
36-
console.log(' --xwalk-shared-library do not support --shared.');
37-
process.exit(1);
36+
if (args['--xwalk-shared-library'] || args['--xwalk-apk-url']) {
37+
if (args['--shared']) {
38+
console.log(' --shared do not support --xwalk-shared-library and --xwalk-apk-url.');
39+
process.exit(1);
40+
} else if (!(args['--xwalk-shared-library'] && args['--xwalk-apk-url'])) {
41+
console.log(' --xwalk-shared-library and --xwalk-apk-url must be used at the same time.');
42+
process.exit(1);
43+
}
3844
}
3945

40-
create.createProject(args._[0], args._[1], args._[2], args._[3], args['--shared'], args['--cli'], args['--xwalk-shared-library']).done();
41-
46+
create.createProject(args._[0], args._[1], args._[2], args._[3], args['--shared'], args['--cli'], args['--xwalk-shared-library'], args['--xwalk-apk-url']).done();

bin/lib/create.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ function validateProjectName(project_name) {
209209
* Returns a promise.
210210
*/
211211

212-
exports.createProject = function(project_path, package_name, project_name, project_template_dir, use_shared_project, use_cli_template, xwalk_shared_library) {
212+
exports.createProject = function(project_path, package_name, project_name, project_template_dir,
213+
use_shared_project, use_cli_template, xwalk_shared_library, xwalk_apk_url) {
213214
var VERSION = fs.readFileSync(path.join(ROOT, 'VERSION'), 'utf-8').trim();
214215

215216
// Set default values for path, package and name
@@ -220,6 +221,7 @@ exports.createProject = function(project_path, package_name, project_name, proje
220221
project_template_dir = typeof project_template_dir !== 'undefined' ?
221222
project_template_dir :
222223
path.join(ROOT, 'bin', 'templates', 'project');
224+
xwalk_apk_url = typeof xwalk_apk_url !== 'undefined' ? xwalk_apk_url : "";
223225

224226
var safe_activity_name = project_name.replace(/\W/g, '');
225227
var package_as_path = package_name.replace(/\./g, path.sep);
@@ -302,6 +304,7 @@ exports.createProject = function(project_path, package_name, project_name, proje
302304
shell.sed('-i', /__ACTIVITY__/, safe_activity_name, manifest_path);
303305
shell.sed('-i', /__PACKAGE__/, package_name, manifest_path);
304306
shell.sed('-i', /__APILEVEL__/, target_api.split('-')[1], manifest_path);
307+
shell.sed('-i', /__XWALKAPKURL__/, xwalk_apk_url, manifest_path);
305308
copyScripts(project_path);
306309
copyBuildRules(project_path);
307310
});

bin/lib/simpleargs.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ exports.getArgs = function(argv) {
2222
var posArgs = [];
2323
for (var i = 2, arg; arg = argv[i] || i < argv.length; ++i) {
2424
if (/^--/.exec(arg)) {
25-
ret[arg] = true;
25+
if (arg.indexOf("=") != -1) {
26+
var arr = arg.split("=");
27+
ret[arr[0]] = arr[1];
28+
} else {
29+
ret[arg] = true;
30+
}
2631
} else {
2732
posArgs.push(arg);
2833
}

bin/templates/project/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<application android:name="org.apache.cordova.CordovaApplication"
3737
android:icon="@drawable/icon" android:label="@string/app_name"
3838
android:hardwareAccelerated="true">
39+
<meta-data android:name="xwalk_apk_url" android:value="__XWALKAPKURL__" />
3940
<activity android:name="__ACTIVITY__"
4041
android:label="@string/activity_name"
4142
android:launchMode="singleTop"

0 commit comments

Comments
 (0)