How can I configure settings.gradle to accommodate different setups based on the flavours of my app?
In my settings.gradle, I have several modules defined, such as:
include ':SubModule1'
include ':SubModule2'
.....
include ':SubModule8'
include ':SubModule10'
Now, I have two flavour dimensions defined: marketOne and marketTwo. Depending on the market, I would like settings.gradle to distinguish between the two markets, for example:
include ':SubModule1'
if(selectedMarket == marketOne) {
include ':SubModule2'
}
.....
if(selectedMarket == marketTwo) {
include ':SubModule8'
}
include ':SubModule10'
Essentially, I need to set the market or some sort of flag in selectedMarket. However, I'm encountering difficulties obtaining the current buildVariant selected in Android Studio during Gradle sync and build.
Do you have any suggestions on how to accomplish this?
I believe
settings.gradlefile is not meant to do what you're looking for. You can include all the submodules in thesettings.gradlefile and then link as dependency the module you need in the app'sbuild.gradlefile, dependencies section:In this way, when the
marketOneflavor is selected then submodule 2 will be included (but not submodule 8). Same thing when themarketTwoflavor is selected.