Gradle Sonarqube task not found

Sonar: 8.9, Gradle Plugin Version: 3.3

I am trying to upgrade to version 3.3 of the gradle plugin (from version 2.8) and in 8.9 documentation for the gradle plugin (SonarScanner for Gradle | SonarQube Docs) I notice that starting with 3.x of the plugin it no longer creates task dependencies to the tasks that generate output. The listed solution is to create these dependencies yourself with project.tasks["sonarqube"].dependsOn "anotherTask". That is easy enough so I have this in my build file:

   project.tasks["sonarqube"].dependsOn "test"

The problem is this causes the error “Task with name ‘sonarqube’ not found in project” during configuration phase of the build on the line where I am setting dependsOn. So why isn’t the sonarqube task available after I apply the org.sonarqube plugin? If I remove the dependsOn line I can execute the sonarqube task so at some point it gets added to the gradle task graph. When during config phase is the sonarqube task actually added to the task graph?

1 Like