'How to define a BuildConfig field for all modules of a project (gradle KTS)?

Is there any way I can create a BuildConfig field for all my modules through the project's build.gradle.kts file?



Solution 1:[1]

Finally. I just found a way on how to do that.

// build.gradle.kts (of the project)

subprojects {
    afterEvaluate {
        (extensions.findByName("android") as? BaseExtension)?.apply {
            defaultConfig {
                buildConfigField("String", "base_url", "\"my.base.url\"")
            }
        }
    }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Augusto Carmo