gradle-infrastructure icon indicating copy to clipboard operation
gradle-infrastructure copied to clipboard

android: Add DSL for BuildConfig fields

Open osipxd opened this issue 3 years ago • 1 comments

It would be nice to have type-safe DSL to add fields to BuildConfig:

buildConfig {
    int("VERSION_CODE", 1) // buildConfigField("int", "VERSION_CODE", "1")
    string("VERSION", "1.0") // buildConfigField("String", "VERSION", "\"1.0\"")
    enum("STAGE", "io.example.Stage.PROD") // buildConfigField("io.example.Stage", "STAGE", "io.example.Stage.PROD")
}

osipxd avatar Jun 21 '22 09:06 osipxd

Another possible way to go - create abstraction over build config field. With this approach we can share field between different build types and flavors:

val stage = buildConfig.enumField("STAGE", "io.example.Stage")

debug {
    stage.set("DEV")
}

release {
    stage.set("PROD")
}

osipxd avatar Mar 01 '23 14:03 osipxd