Skip to content

Commit

Permalink
chore: find build-tools version automatically
Browse files Browse the repository at this point in the history
Signed-off-by: Next Alone <12210746+NextAlone@users.noreply.github.com>
  • Loading branch information
NextAlone committed Jun 22, 2023
1 parent 59d3946 commit d0e3870
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion build-logic/convention/src/main/kotlin/Version.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ object Version {
val java = JavaVersion.VERSION_11

const val compileSdkVersion = 33
const val buildToolsVersion = "33.0.1"
val buildToolsVersion = findBuildToolsVersion()
const val minSdk = 24
const val targetSdk = 33
const val versionName = "1.4.1"
Expand Down Expand Up @@ -49,4 +49,10 @@ object Version {
private fun getEnvVariable(name: String): String? {
return System.getenv(name)
}

private fun findBuildToolsVersion(): String {
val defaultBuildToolsVersion = "33.0.0"
return File(System.getenv("ANDROID_HOME"), "build-tools").listFiles()?.filter { it.isDirectory }?.maxOfOrNull { it.name }?.also { println("Using build tools version $it") }
?: defaultBuildToolsVersion
}
}

0 comments on commit d0e3870

Please sign in to comment.