dependency-analysis-gradle-plugin
dependency-analysis-gradle-plugin copied to clipboard
[Question] Exclude Certain flavor & Build Type
My project currently has 17 flavor & 4 build type, that means 68 combination of build type & flavor task and additional task generated for each combination. I have managed to exclude flavor & build type using the following script
gradle.taskGraph.whenReady { graph ->
if (project.hasProperty("onlyDebug")) {
def targetTaskPatterns = [
/(?i).*androidTest.*/
, /(?i).*UnitTest.*/
, /(?i).*Release.*/
, /(?i).*Benchmark.*/
, /(?i).*BenchmarkKotlin.*/
, /(?i).*MockKotlin.*/
, /(?i).*Mock.*/
, /(?i).*Production.*/
, /(?i).*PreSubAutomation.*/
, /(?i).*Preprod.*/
, /(?i).*Sit04.*/
, /(?i).*Sit03.*/
, /(?i).*Sit02.*/
, /(?i).*Sit01.*/
, /(?i).*Publicsit.*/
, /(?i).*Sandbox2.*/
, /(?i).*Sandbox.*/
, /(?i).*Integration06.*/
, /(?i).*Integration05.*/
, /(?i).*Integration04.*/
, /(?i).*Integration03.*/
, /(?i).*Integration02.*/
, /(?i).*Integration01.*/
]
graph.allTasks.each { task ->
targetTaskPatterns.each { pattern ->
if (task.name =~ pattern) {
println("Match pattern to disable")
println(task.name)
task.enabled = false
}
}
}
}
}
However, it seems task "> A failure occurred while executing com.autonomousapps.tasks.ComputeAdviceTask$ComputeAdviceAction" still expect all flavor and build type to be compiled somehow because i got this error "app/build/reports/dependency-analysis/integration01DebugTest/graph/graph-compile.json (No such file or directory)"
Is there a way to exclude certain flavor & build type so i can run this plugin faster without compiling all combination of flavor & build type ?
Thank you
Aditionally, I was able to make it run only 1 combination of build type & flavor by manually comment out build type & flavor.
What i am looking for is like Sonarcube configuration where you can choose certain build flavor so you dont run all combination of build types and flavor
sonarqube {
androidVariant 'dev01Debug'
...
}
Thanks for the question. Your methodology for excluding variants (disabling tasks) is not the right way to go about it. Instead, please use the appropriate AGP API. See the docs here.
Alternatively, you could use the flag -Pdependency.analysis.android.ignored.variants=variant1,variant2,variant3
to ignore specific Android variants. This is since v1.18.0.
Thanks for the question. Your methodology for excluding variants (disabling tasks) is not the right way to go about it. Instead, please use the appropriate AGP API. See the docs here.
Alternatively, you could use the flag
-Pdependency.analysis.android.ignored.variants=variant1,variant2,variant3
to ignore specific Android variants. This is since v1.18.0.
Thank you, i'll check this out
Variant exclusion does not work for all use cases. For example, as far as I can see, disabling instrumented tests can only be achieved by disabling their tasks (and dependency.analysis.android.ignored.variants
does not help here)
EDIT: disabling by source set might help here. Will check it out.