You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by na...@apache.org on 2014/10/02 20:17:53 UTC

[19/29] git commit: CB-7512: Fix logic for detecting SDK directory

CB-7512: Fix logic for detecting SDK directory


Project: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/commit/9062a78b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/tree/9062a78b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/diff/9062a78b

Branch: refs/heads/master
Commit: 9062a78bc41307575ed97bc125b341623c04b6aa
Parents: 82b77c3
Author: Ian Clelland <ic...@chromium.org>
Authored: Mon Sep 15 12:15:32 2014 -0400
Committer: Prabhjot Singh <pr...@amazon.com>
Committed: Wed Sep 17 18:38:38 2014 +0530

----------------------------------------------------------------------
 bin/templates/project/cordova.gradle | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/blob/9062a78b/bin/templates/project/cordova.gradle
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova.gradle b/bin/templates/project/cordova.gradle
index f552a47..6c7d0ab 100644
--- a/bin/templates/project/cordova.gradle
+++ b/bin/templates/project/cordova.gradle
@@ -84,9 +84,13 @@ int compareVersions(String a, String b) {
 
 String getAndroidSdkDir() {
     def rootDir = project.rootDir
+    def androidSdkDir = null
+    String envVar = System.getenv("ANDROID_HOME")
     def localProperties = new File(rootDir, 'local.properties')
-    def androidSdkDir = ""
-    if (localProperties.exists()) {
+    String systemProperty = System.getProperty("android.home")
+    if (envVar != null) {
+        androidSdkDir = envVar
+    } else if (localProperties.exists()) {
         Properties properties = new Properties()
         localProperties.withInputStream { instr ->
             properties.load(instr)
@@ -98,23 +102,16 @@ String getAndroidSdkDir() {
             sdkDirProp = properties.getProperty('android.dir')
             if (sdkDirProp != null) {
                 androidSdkDir = (new File(rootDir, sdkDirProp)).getAbsolutePath()
-            } else {
-                throw new RuntimeException(
-                        "No sdk.dir property defined in local.properties file.")
-            }
-        }
-    } else {
-        String envVar = System.getenv("ANDROID_HOME")
-        if (envVar != null) {
-            androidSdkDir = envVar
-        } else {
-            String property = System.getProperty("android.home")
-            if (property != null) {
-                androidSdkDir = property
             }
         }
     }
-    println androidSdkDir
+    if (androidSdkDir == null && systemProperty != null) {
+        androidSdkDir = systemProperty
+    }
+    if (androidSdkDir == null) {
+        throw new RuntimeException(
+            "Unable to determine Android SDK directory.")
+    }
     androidSdkDir
 }
 


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