mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-31 17:32:51 +08:00
CB-7512: Fix logic for detecting SDK directory
This commit is contained in:
parent
f9b89e98c2
commit
4be92f285a
@ -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 {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (androidSdkDir == null && systemProperty != null) {
|
||||
androidSdkDir = systemProperty
|
||||
}
|
||||
if (androidSdkDir == null) {
|
||||
throw new RuntimeException(
|
||||
"No sdk.dir property defined in local.properties file.")
|
||||
"Unable to determine Android SDK directory.")
|
||||
}
|
||||
}
|
||||
} 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
|
||||
androidSdkDir
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user