Skip to content

Instantly share code, notes, and snippets.

@fleficher
Last active January 29, 2020 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fleficher/d155a4c28c6861b80e1c5277bb878f6d to your computer and use it in GitHub Desktop.
Save fleficher/d155a4c28c6861b80e1c5277bb878f6d to your computer and use it in GitHub Desktop.
// 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