I have several types of assembly: debug , release . I also have two flavors pub and dev .
pub flavored application depends on the pub library, which is similar for dev flavor. Now, I would like a debug type application to depend on the build of the debug library. The following does not work:
pubReleaseCompile project(path: ':common', configuration: "pubRelease") devReleaseCompile project(path: ':common', configuration: "devRelease") pubDebugCompile project(path: ':common', configuration: "pubDebug") devDebugCompile project(path: ':common', configuration: "devDebug")
Note. The library is configured to compile all options.
Is there a way to specify a conditional project dependency based on both taste and build type?
EDIT: To avoid confusion, follow the appropriate build.gradle files from the project I am currently using.
project / common / build.gradle (library)
apply plugin: 'com.android.library' apply plugin: 'com.jakewharton.hugo' // annotation-based code generated logs only in debug build android { defaultPublishConfig "pubRelease" publishNonDefault true // four variants of the library are built buildTypes { debug {} release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } productFlavors { pub { // custom build config fields } dev { // custom build config fields } } } dependencies { // ... }
project / parent / build.gradle (one of the application modules using the library)
apply plugin: 'com.android.application' apply plugin: 'com.jakewharton.hugo' android { // ... signingConfigs { release { // ... } } buildTypes { release { signingConfig signingConfigs.release proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt' shrinkResources true minifyEnabled true } debug { versionNameSuffix '-debug' } } productFlavors { pub { // custom res values } dev { // custom res values } } } dependencies { // ... pubCompile project(path: ':common', configuration: "pubRelease") devCompile project(path: ':common', configuration: "devRelease") }
android gradle
Eugen Pechanec Jan 25 '15 at 15:03 2015-01-25 15:03
source share