The approach described in the documentation doesn’t work since running the sonarqube
task also executes the JavaCompile tasks.
I came across the same problem in our build pipelines. It appears to be a bug - SonarScanner for Gradle adds dependencies on JavaCompile tasks