I definitively want to support flavors and build types in libraries the same way we do in application project.
There are some issues with it though. while you can write
This doesnt really scale. You would actually need to set this up like:
flavor1Compile project(path: ':foo', configuration: 'flavor1')
flavor2Compile project(path: ':foo', configuration: 'flavor2')
You'd have to do this for all you variant. And actually, that's not quite right either, you actually need:
flavor1DebugCompile project(path: ':foo', configuration: 'flavor1Debug')
flavor2ReleaseCompile project(path: ':foo', configuration: 'flavor2Release')
Where those configurations are composite configuration that are made up of all the configuration that make up your variant (the default compile, the build type and flavors if applicable).
I'm actually working on creating those composite configuration objects because we need to resolve the dependencies of a variant as a whole, instead of resolving each (default config, build type, flavors) separately and then combining the result like we were doing before.
However we don't want developers to setup dependencies on those composite configurations, they are purely internal implementation details.
(Those we want developers to create custom resolutionStrategy on the composite, not on the single configuration!).
So to get back to the library project. What you really want is just say:
compile project(':foo')
and have gradle do the right thing, which is let the plugin query what artifacts of 'foo' are available and choose the right one base on what variant is currently being compiled (since 'compile' is used by all the variant).
If both app and library use the same buildtypes/flavors then we just use the right one automatically. If they are different, we could let the user provide some mapping to help. But in some case we can figure it out automatically.
For instance if the app has (debug, release)x(flavor1, flavor2) and the library has (debug, release) only we can do the matching directly based on the build type.
If the library has (debug,release)x(flavor3, flavor4) then we'll need to know the mapping.
In all case it's better than having the app explicitly define dependencies on the variant directly.
Gradle right now is missing some hooks to do that. I actually just spent all of yesterday talking with the Gradle lead developer and we spent a *lot* of time talking about dependency management (there are other features that are tied to dependency management that we need to improve on both sides).
Improving the dependency management in Gradle to support Android's use case is going to be high on our priority list, so we'll get there.
Xav