The question was: how to access from your Kotlin code, a arbitrary value that exists in build.gradle.kt?
If you have the following entry in my build.gradle.kt file (trying to add a feature flag):
android {
...
buildTypes {
getByName("debug") {
buildConfigField("Boolean", "FOO", "true")
}
getByName("release") {
buildConfigField("Boolean", "FOO", "false")
}
}
...
}
A way to access the value of FOO within your Kotlin code is:
class FeatureFlag {
fun isFeatureEnabled(): Boolean = BuildConfig.FOO
}