You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ni...@apache.org on 2016/05/06 17:44:38 UTC
android commit: CB-11198 Skip android target sdk check. This closes
#303.
Repository: cordova-android
Updated Branches:
refs/heads/master d351e316b -> 5d21fb26e
CB-11198 Skip android target sdk check. This closes #303.
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/5d21fb26
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/5d21fb26
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/5d21fb26
Branch: refs/heads/master
Commit: 5d21fb26e623f8ac847c26050477421a201e54e0
Parents: d351e31
Author: Nikhil Khandelwal <ni...@microsoft.com>
Authored: Tue May 3 16:02:02 2016 -0700
Committer: Nikhil Khandelwal <ni...@microsoft.com>
Committed: Fri May 6 10:44:14 2016 -0700
----------------------------------------------------------------------
bin/lib/check_reqs.js | 38 ++++++++++----------
.../cordova/lib/builders/AntBuilder.js | 17 ++++++++-
.../cordova/lib/builders/GradleBuilder.js | 9 +++++
3 files changed, 45 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/5d21fb26/bin/lib/check_reqs.js
----------------------------------------------------------------------
diff --git a/bin/lib/check_reqs.js b/bin/lib/check_reqs.js
index 73b2b99..f27f325 100644
--- a/bin/lib/check_reqs.js
+++ b/bin/lib/check_reqs.js
@@ -142,22 +142,20 @@ module.exports.check_java = function() {
}
}
}).then(function() {
- var msg =
- 'Failed to run "java -version", make sure that you have a JDK installed.\n' +
- 'You can get it from: http://www.oracle.com/technetwork/java/javase/downloads.\n';
- if (process.env['JAVA_HOME']) {
- msg += 'Your JAVA_HOME is invalid: ' + process.env['JAVA_HOME'] + '\n';
- }
- return tryCommand('java -version', msg)
- .then(function() {
+ var msg =
+ 'Failed to run "javac -version", make sure that you have a JDK installed.\n' +
+ 'You can get it from: http://www.oracle.com/technetwork/java/javase/downloads.\n';
+ if (process.env['JAVA_HOME']) {
+ msg += 'Your JAVA_HOME is invalid: ' + process.env['JAVA_HOME'] + '\n';
+ }
// We use tryCommand with catchStderr = true, because
// javac writes version info to stderr instead of stdout
- return tryCommand('javac -version', msg, true);
- }).then(function (output) {
- var match = /javac ((?:\d+\.)+(?:\d+))/i.exec(output)[1];
- return match && match[1];
+ return tryCommand('javac -version', msg, true)
+ .then(function (output) {
+ var match = /javac ((?:\d+\.)+(?:\d+))/i.exec(output);
+ return match && match[1];
+ });
});
- });
};
// Returns a promise.
@@ -238,13 +236,13 @@ module.exports.getAbsoluteAndroidCmd = function () {
return cmd.replace(/(\s)/g, '\\$1');
};
-module.exports.check_android_target = function(valid_target) {
+module.exports.check_android_target = function(originalError) {
// valid_target can look like:
// android-19
// android-L
// Google Inc.:Google APIs:20
// Google Inc.:Glass Development Kit Preview:20
- if (!valid_target) valid_target = module.exports.get_target();
+ var valid_target = module.exports.get_target();
var msg = 'Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.';
return tryCommand('android list targets --compact', msg)
.then(function(output) {
@@ -254,18 +252,22 @@ module.exports.check_android_target = function(valid_target) {
}
var androidCmd = module.exports.getAbsoluteAndroidCmd();
- throw new CordovaError('Please install Android target: "' + valid_target + '".\n\n' +
+ var msg = 'Please install Android target: "' + valid_target + '".\n\n' +
'Hint: Open the SDK manager by running: ' + androidCmd + '\n' +
'You will require:\n' +
'1. "SDK Platform" for ' + valid_target + '\n' +
'2. "Android SDK Platform-tools (latest)\n' +
- '3. "Android SDK Build-tools" (latest)');
+ '3. "Android SDK Build-tools" (latest)';
+ if (originalError) {
+ msg = originalError + '\n' + msg;
+ }
+ throw new CordovaError(msg);
});
};
// Returns a promise.
module.exports.run = function() {
- return Q.all([this.check_java(), this.check_android().then(this.check_android_target)])
+ return Q.all([this.check_java(), this.check_android()])
.then(function() {
console.log('ANDROID_HOME=' + process.env['ANDROID_HOME']);
console.log('JAVA_HOME=' + process.env['JAVA_HOME']);
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/5d21fb26/bin/templates/cordova/lib/builders/AntBuilder.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/lib/builders/AntBuilder.js b/bin/templates/cordova/lib/builders/AntBuilder.js
index 7094fe5..5b2b104 100644
--- a/bin/templates/cordova/lib/builders/AntBuilder.js
+++ b/bin/templates/cordova/lib/builders/AntBuilder.js
@@ -107,7 +107,22 @@ AntBuilder.prototype.build = function(opts) {
var args = this.getArgs(opts.buildType == 'debug' ? 'debug' : 'release', opts);
return check_reqs.check_ant()
.then(function() {
- return spawn('ant', args, {stdio: 'inherit'});
+ return spawn('ant', args, {stdio: 'pipe'});
+ }).progress(function (stdio){
+ if (stdio.stderr) {
+ process.stderr.write(stdio.stderr);
+ } else {
+ process.stdout.write(stdio.stdout);
+ }
+ }).catch(function (error) {
+ if (error.toString().indexOf('Unable to resolve project target') >= 0) {
+ return check_reqs.check_android_target(error).then(function() {
+ // If due to some odd reason - check_android_target succeeds
+ // we should still fail here.
+ return Q.reject(error);
+ });
+ }
+ return Q.reject(error);
});
};
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/5d21fb26/bin/templates/cordova/lib/builders/GradleBuilder.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/lib/builders/GradleBuilder.js b/bin/templates/cordova/lib/builders/GradleBuilder.js
index 0f83659..325ea55 100644
--- a/bin/templates/cordova/lib/builders/GradleBuilder.js
+++ b/bin/templates/cordova/lib/builders/GradleBuilder.js
@@ -203,6 +203,15 @@ GradleBuilder.prototype.build = function(opts) {
} else {
process.stdout.write(stdio.stdout);
}
+ }).catch(function (error) {
+ if (error.toString().indexOf('failed to find target with hash string') >= 0) {
+ return check_reqs.check_android_target(error).then(function() {
+ // If due to some odd reason - check_android_target succeeds
+ // we should still fail here.
+ return Q.reject(error);
+ });
+ }
+ return Q.reject(error);
});
};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org