cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bows...@apache.org
Subject [03/10] android commit: CB-12524: Windows functionality for Gradle execution
Date Mon, 13 Mar 2017 20:51:46 GMT
CB-12524: Windows functionality for Gradle execution


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/ab276504
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/ab276504
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/ab276504

Branch: refs/heads/master
Commit: ab276504fde9c046b0018d9f4d39d5cb21600238
Parents: 3cc4e5b
Author: Joe Bowser <bowserj@gmail.com>
Authored: Thu Mar 9 10:26:48 2017 -0800
Committer: Joe Bowser <bowserj@apache.org>
Committed: Mon Mar 13 13:51:36 2017 -0700

----------------------------------------------------------------------
 bin/lib/check_reqs.js                            | 19 +++++++++----------
 .../cordova/lib/builders/GradleBuilder.js        | 10 +++++++---
 2 files changed, 16 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/ab276504/bin/lib/check_reqs.js
----------------------------------------------------------------------
diff --git a/bin/lib/check_reqs.js b/bin/lib/check_reqs.js
index 6b3a630..c6898e7 100644
--- a/bin/lib/check_reqs.js
+++ b/bin/lib/check_reqs.js
@@ -81,17 +81,17 @@ module.exports.check_ant = function() {
 
 module.exports.get_gradle_wrapper = function() {
     var androidStudioPath;
-    if(os.platform() == "darwin") {
+    if(os.platform() == 'darwin') {
       androidStudioPath = path.join('/Applications', 'Android Studio.app', 'Contents', 'gradle');
+    } else if (os.platform() == 'win32') {
+      androidStudioPath = path.join(process.env['ProgramFiles'],'Android', 'Android Studio',
'gradle');
     }
 
-    if(androidStudioPath != null && fs.existsSync(androidStudioPath)) {
+    if(androidStudioPath !== null && fs.existsSync(androidStudioPath)) {
       var dirs = fs.readdirSync(androidStudioPath);
-      if(dirs[0].split('-')[0] == "gradle")
+      if(dirs[0].split('-')[0] == 'gradle')
       {
-        //Sweet, we found the path, let's return it.
-        var gradle_cmd = os.platform() == "win32" ? "gradle.bat" : "gradle";
-        return path.join(androidStudioPath, dirs[0], "bin", gradle_cmd);
+        return path.join(androidStudioPath, dirs[0], 'bin', 'gradle');
       }
     } else {
       //OK, let's try to check for Gradle!
@@ -107,10 +107,9 @@ module.exports.check_gradle = function() {
         return Q.reject(new CordovaError('Could not find gradle wrapper within Android SDK.
Could not find Android SDK directory.\n' +
             'Might need to install Android SDK or set up \'ANDROID_HOME\' env variable.'));
 
-    var path = this.get_gradle_wrapper();
-    console.log(path);
-    if(path != '')
-      d.resolve(path);
+    var gradlePath = this.get_gradle_wrapper();
+    if(gradlePath.length !== 0)
+      d.resolve(gradlePath);
     else
       d.reject(new CordovaError('Could not find an installed version of Gradle either in
Android Studio,\n' +
                                 'or on your system to install the gradle wrapper. Please
include gradle \n' +

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/ab276504/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 2404777..6bad2d2 100644
--- a/bin/templates/cordova/lib/builders/GradleBuilder.js
+++ b/bin/templates/cordova/lib/builders/GradleBuilder.js
@@ -70,9 +70,13 @@ GradleBuilder.prototype.getArgs = function(cmd, opts) {
  */
 
 GradleBuilder.prototype.runGradleWrapper = function(gradle_cmd) {
-  if(!fs.existsSync(this.root, 'gradle'))
-    return spawn(gradle_cmd, ["wrapper"], {stdio: 'inherit'});
-}
+    var gradlePath = path.join(this.root, 'gradlew');
+    if(fs.existsSync(gradlePath)) {
+      //Literally do nothing, for some reason this works, while !fs.existsSync didn't on
Windows
+    } else {
+      return spawn(gradle_cmd, ['wrapper'], {stdio: 'inherit'});
+    }
+};
 
 
 // Makes the project buildable, minus the gradle wrapper.


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message