Build type support for Java modules in Android project


I have an Android Gradle project which consists of the Android module and 3 Java library modules (that the Android module depends on).

The Android Gradle plugin supports build types (debug, release, etc) and I’d like to be able to use these build types for the library projects as well, so that if I enable debug, it would use debug source sets for all 4 modules.

However, I’m not quite sure how to make this happen for the pure Java modules. I know I can define new sourceSets, but is there anyway to configure the Gradle build scripts so that the sourceSets of the Java modules change when I change build type for the Android module?


it is not yet possible to use build variant from an Android project in non-Android projects. The idea is to have similar functionality there in the future.