Okay, so I have different product flavors and I have different submodules. Right to implement submodule, I do this:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(path: ':A-Android')
implementation project(path: ':B-Android')
implementation project(path: ':C-Android')
}
Is it possible to implement, for instance, submodule :A-Android
only for specific product flavor? How?
Yes, can configure dependencies only for specific flavor. Here an excerpt from Declare dependencies documentation :
Declare dependencies
You can configure a dependency for a specific build variant or testing source set by prefixing the name of the build variant or testing source set before the Implementation keyword, as shown in the following example.
dependencies { // Adds the local "mylibrary" module as a dependency to the "free" flavor. freeImplementation project(":mylibrary") // Adds a remote binary dependency only for local tests. testImplementation 'junit:junit:4.12' // Adds a remote binary dependency only for the instrumented test APK. androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' }
For more information, see Add build dependencies.
So, if you have two flavors something like production
and development
flavor, then you can add the dependencies like this:
dependencies {
productionImplementation project(path: ':A-Android')
DevelopmentImplementation project(path: ':B-Android')
..
}