Android Studio - Gradle builds all flavors of library instead of only current one -
my app consists of main module mobile
, library module core
. each of them has 2 build flavors: flavor1
, flavor2
.
library build.gradle:
apply plugin: 'com.android.library' android { .... publishnondefault true productflavors { flavor1 {} flavor2 {} } }
project build.gradle:
apply plugin: 'com.android.application' android { .... productflavors { flavor1 {} flavor2 {} } } configurations { flavor1debugcompile flavor2debugcompile flavor1releasecompile flavor2releasecompile } dependencies { .... flavor1debugcompile project(path: ':core', configuration: 'flavor1debug') flavor2debugcompile project(path: ':core', configuration: 'flavor2debug') flavor1releasecompile project(path: ':core', configuration: 'flavor1release') flavor2releasecompile project(path: ':core', configuration: 'flavor2release') }
now works , compiles, noticed strange in how gradle builds library:
if assemble library, doing gradlew :core:assembleflavor1debug
- compile code flavor1
(i see task core:compileflavor1debugjavawithjavac
being executed).
however when try build project (or pressing 'run' button) - gradlew :mobile:assembleflavor1debug
see in output, library built both build flavors, calling core:compileflavor1debugjavawithjavac
, core:compileflavor2debugjavawithjavac
, thought selected build flavor1
only!
now, looks strange me, why build flavors instead of required flavor only? bug in gradle or way handles libraries?
Comments
Post a Comment