Dynamic Gradle compile dependencies for different buildConfigFields

Viewed 337

In my project, I'm using different configurations based on different buildConfigFields, and for some of them I don't use certain dependencies. So I don't want to have certain dependencies in specific configs, depending on the buildConfigFields.

How can I do something similar to the following?

dependencies {
    if (buildConfigField("String", "WHICH_MESSAGE_ENABLED") == "VALUE") {
        compile "xxx.yyy.zz:1.0"
    } else {
        provided "xxx.yyy.zz:1.0"
    }
}
1 Answers
Related