How do I use setIgnore on a local library either from the apps build.gradle or the library build.gradle based on the apps flavor. I am not sure if I can reference the apps build.gradle flavor/dimension from the library build.gradle. I also don't know if I can reference a library from the apps build.gradle and use lib.setIgnore(true). Any solution to solving this issue?
I am currently only using one dimension for the application and multiple flavors.
This is how it is typically done; but I need to set Ignore on a library based on the apps flavor.
android { ... variantFilter { variant -> if(variant.buildType.name == 'release' && variant.getFlavors().get(0).name == 'vanilla') { variant.setIgnore(true) } } }
2 Answers
Answers 1
Maybe you can use the library only when you need.
dependencies { // use "mylib" for debug debugImplementation project(path: ':mylib') // all the flavors implementation "com.android.support:appcompat-v7:28.0.0' }
Answers 2
You can try to wait for the task graph to be assembled and then removes the undesired name pattern as follows:
gradle.taskGraph.whenReady { graph -> graph.allTasks.findAll { it.name ==~ /.*vanilla.*/ }*.enabled = false }
0 comments:
Post a Comment