From ccdd94c99781c69cbe1ba633d7ff1e287c808092 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 5 Oct 2014 12:34:00 +0200 Subject: [PATCH] Add check if ANDROID_HOME is set to build.gradle --- build.gradle | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 89f558b14..8400ee8f1 100644 --- a/build.gradle +++ b/build.gradle @@ -312,8 +312,7 @@ def getGitCommit() { } def getAndroidRuntimeJar() { - def androidHome = new File("$System.env.ANDROID_HOME") - if (!androidHome.isDirectory()) throw new Exception("ANDROID_HOME not found or set") + def androidHome = getAndroidHome() def androidJar = new File("$androidHome/platforms/android-$smackMinAndroidSdk/android.jar") if (androidJar.isFile()) { return androidJar @@ -323,7 +322,16 @@ def getAndroidRuntimeJar() { } def getAndroidJavadocOffline() { - def androidHome = new File("$System.env.ANDROID_HOME") - if (!androidHome.isDirectory()) throw new Exception("ANDROID_HOME not found or set") - return "$System.env.ANDROID_HOME" + "/docs/reference" + def androidHome = getAndroidHome() + return androidHome.toString() + "/docs/reference" } + +def getAndroidHome() { + def androidHomeEnv = System.getenv("ANDROID_HOME") + if (androidHomeEnv == null) { + throw new Exception("ANDROID_HOME environment variable is not set") + } + def androidHome = new File(androidHomeEnv) + if (!androidHome.isDirectory()) throw new Exception("Environment variable ANDROID_HOME is not pointing to a directory") + return androidHome +} \ No newline at end of file