I'm trying to configure a build for Android. The project has many flavors, and in one flavor, I want to replace some classes from main. The structure is like this:
main - MyClass.java
flavorA, flavorB... flavorF use main's MyClass.java, no override
flavorG needs its own MyClass.java
I don't want to copy MyClass.java into each flavor's directory & remove it from main entirely, that would not be maintainable. Is there a way to use the exclude command to accomplish this? Something like...
+ src
+ main
+ java
MyClass.java
other common files
AndroidManifest.xml
+ flavorA
+ java
other flavor-specific files
AndroidManifest.xml
+ flavorG
+ java
MyClass.java
other flavor-specific files
AndroidManifest.xml
With a gradle setup like this...
productFlavors {
flavora {
}
...
flavorg {
}
}
sourceSources {
flavora {
}
flavorb {
}
...
flavorg {
main.java {
exclude 'com/myapp/mypackage/MyClass.java'
}
}
}
The above doesn't work, am I doing something wrong? Is there another alternative?