Allow Gradle task to run without other tasks as dependencies

Context: Android multi-module project, using Kotlin, using the SonarScanner Gradle plugin

We have a CI pipeline that splits out various checks (lint, test, build, etc) into separate jobs, so that we can run them in parallel. After these jobs have all completed, we run the sonar Gradle task in another job that includes any required artifacts generated by the previous jobs (e.g. the coverage report).

However, the sonar task depends upon various build / test tasks (see: sonar-scanner-gradle/ at a4f267175a438d81904899d923c67919df2cafdc · SonarSource/sonar-scanner-gradle · GitHub), which means that the SonarScanner task takes longer than is needed. We would like to be able to opt out of these task dependencies, and thus speed up this job, since anything that the SonarScanner plugin needs has already been computed in a prior task


If you exclude the tasks from your sonar build (e.g. gradle sonar -x jar), then it won’t be run. with enough exclusions, you can run the sonar task only. Hope that solves your issue!


Thanks for the suggestions @steve.marion - this led to us using tasks.sonar.dependsOn.clear() (we have a lot of module so specifying all of the tasks to exclude via command line wouldn’t have been great to manage), which seems to have done the trick!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.