forked from MarathonLabs/marathon
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d448ab9
commit d7af783
Showing
10 changed files
with
76 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/android/AdbFinder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.malinskiy.marathon.android | ||
|
||
import com.android.SdkConstants.FN_LOCAL_PROPERTIES | ||
import java.io.File | ||
import java.util.* | ||
|
||
fun findAdbPath(rootDir: File): File { | ||
val localProperties = File(rootDir, FN_LOCAL_PROPERTIES) | ||
val properties = Properties() | ||
|
||
if (localProperties.isFile) { | ||
localProperties.bufferedReader().use { | ||
properties.load(it) | ||
} | ||
} | ||
|
||
return findSdkLocation(properties, rootDir) | ||
?.resolve("platform-tools") | ||
?.resolve("adb") | ||
?: throw RuntimeException("SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.") | ||
} | ||
|
||
private fun findSdkLocation(properties: Properties, rootDir: File): File? { | ||
var sdkDirProp: String? = properties.getProperty("sdk.dir") | ||
if (sdkDirProp != null) { | ||
var sdk = File(sdkDirProp) | ||
if (!sdk.isAbsolute) { | ||
sdk = rootDir.resolve(sdkDirProp) | ||
} | ||
return sdk | ||
} | ||
|
||
sdkDirProp = properties.getProperty("android.dir") | ||
if (sdkDirProp != null) { | ||
return rootDir.resolve(sdkDirProp) | ||
} | ||
|
||
val envVar = System.getenv("ANDROID_HOME") | ||
if (envVar != null) { | ||
var sdk = File(envVar) | ||
if (!sdk.isAbsolute) { | ||
sdk = rootDir.resolve(envVar) | ||
} | ||
return sdk | ||
} | ||
|
||
val property = System.getProperty("android.home") | ||
return when { | ||
property != null -> File(property) | ||
else -> null | ||
} | ||
} |
73 changes: 0 additions & 73 deletions
73
marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/android/SdkFinder.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters