inherit product flavor
I have 3 product flavors excluding the main
one:
productFlavors {
xxx {
applicationId 'com.xxx'
}
yyy {
applicationId 'com.yyy'
}
zzz {
applicationId 'com.zzz'
}
}
As I understand it, these product flavors inherit main
's resources and it looks something like this:
+------->xxx
|
main----+------->yyy
|
+------->zzz
So when I build xxx
, Gradle bundles stuff from src/main
and from src/xxx
folders.
Now, I need it to look like this:
+------->xxx
|
main----+------->yyy------->zzz
In other words, I want zzz
to use yyy
's resources as well as main
's. Can Gradle do this?
It may depends on what exactly you want to "override" in zzz. In my project I need productFlavor inheritance too. But I needed override manifest only. I created directory for zzz with custom AndroidManifest.xml and changed other zzz src paths to yyy in build.gradle:
sourceSets {
zzz.java.srcDirs = ['src/yyy/java']
zzz.res.srcDirs = ['src/yyy/res']
...
...
}
productFlavors {
xxx {}
yyy {}
zzz {}
}
PS Created a feature request for this https://code.google.com/p/android/issues/detail?id=183350
I have answered this in another thread. I will just copy and paste my answer here, hoping it will be helpful to you.
I was looking for a similar thing in gradle and found Multi-flavor variants. I have an app that should have versions A and B, and each version has dev and pro environments, so I ended up with this in my gradle:
flavorDimensions 'app', 'environment'
productFlavors {
versionA {
flavorDimension 'app'
}
versionB {
flavorDimension 'app'
}
pre {
flavorDimension 'environment'
}
pro {
flavorDimension 'environment'
}
}
And in my build variants I have versionAPreDebug, versionAPreRelease, versionBPreDebug, versionBPreRelease, etc. I think what you need is something like that.
This is a duplicate of Have a product flavor be a child of another
My answer over there may be of help.
链接地址: http://www.djcxy.com/p/27794.html下一篇: 继承产品风味