Android Plugin for Gradle 3.x.x
Build plugin 3.x.x uses variant-aware dependency resolution so devDebug variant of an app module will automatically use devDebug variant of its library module dependency. To answer the question, this would be enough:
implementation project(':common')
Read more here: https://developer.android.com/studio/build/dependencies.html#variant_aware
Original answer
I was able to find a solution here: https://github.com/JakeWharton/u2020/blob/master/build.gradle
More on why my original code does not suffice is available here: https://code.google.com/p/android/issues/detail?id=162285
Working solution:
configurations {
pubDebugCompile
devDebugCompile
pubReleaseCompile
devReleaseCompile
}
dependencies {
pubReleaseCompile project(path: ':common', configuration: "pubRelease")
devReleaseCompile project(path: ':common', configuration: "devRelease")
pubDebugCompile project(path: ':common', configuration: "pubDebug")
devDebugCompile project(path: ':common', configuration: "devDebug")
}