Permalink
Browse files

Check local.properties for sdk.dir

  • Loading branch information...
1 parent 428542f commit ab68dc480c8584b4eccbb66141969747bf68cf37 @jberkel committed Mar 17, 2012
Showing with 16 additions and 5 deletions.
  1. +16 −5 src/main/scala/AndroidPath.scala
@@ -17,10 +17,21 @@ object AndroidPath {
idlPath <<= (platformToolsPath, aidlName) (_ / _),
dxPath <<= (platformToolsPath, osDxName) (_ / _),
- sdkPath <<= (envs) { es =>
- determineAndroidSdkPath(es).getOrElse(sys.error(
- "Android SDK not found. You might need to set %s".format(es.mkString(" or "))
- ))
+ sdkPath <<= (envs, baseDirectory) { (es, dir) =>
+ determineAndroidSdkPath(es).getOrElse {
+ val local = new File(dir, "local.properties")
+ if (local.exists()) {
+ (for (sdkDir <- (for (l <- IO.readLines(local);
+ if (l.startsWith("sdk.dir")))
+ yield l.substring(l.indexOf('=')+1)))
+ yield new File(sdkDir)).headOption.getOrElse(
+ sys.error("local.properties did not contain sdk.dir")
+ )
+ } else sys.error(
+ "Android SDK not found. You might need to set %s".format(es.mkString(" or "))
+ )
+ }
}
- ) }
+ )
+ }
}

0 comments on commit ab68dc4

Please sign in to comment.