Thanks for your message. The problem is that if you’re using the Gradle scanner and its execution task actually depends on the compile
tasks. This way, you will always build a project before analyzing it when executing sonarqube task. We still have discussions about whether it’s a good approach or not.
For now, you can try to exclude compile
tasks (compileJava, compileTestJava, compileKotlin, etc…). Another possible solution could be to use is to add target and source compatibility in your grade configuration:
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
Note, there were already some threads about this issue, so you can find some more information there:
-
SonarScanner for Gradle adds dependencies on JavaCompile tasks
-
Passing Java 11 to SonarQube using Gradle with Java 8 - #8 by TurekBot
-
Integrating Gradle code (Java 8 ) with Sonar 9 - #3 by Margarita_Nedzelska
Regards,
Margarita