Last active
January 29, 2020 13:16
-
-
Save fleficher/d155a4c28c6861b80e1c5277bb878f6d to your computer and use it in GitHub Desktop.
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
// In your buildSrc folder | |
sealed class BuildType(val secret: String) { | |
object DebugBuildType : BuildType(secret = "sword") | |
object ReleaseBuildType : BuildType(secret = "shield") | |
} | |
fun BuildType.getConfiguration(): BuildType { | |
return when (this.name) { | |
"release" -> BuildType.ReleaseBuildType | |
else -> BuildType.DebugBuildType | |
} | |
} | |
// In your app build.gradle.kts | |
buildTypes { | |
getByName("debug") { | |
val configuration = getConfiguration() | |
manifestPlaceholders = mapOf("secret" to configuration.secret) | |
} | |
getByName("release") { | |
val configuration = getConfiguration() | |
manifestPlaceholders = mapOf("secret" to configuration.secret) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment