I am getting an error while running sonarqube on gradle 5, the error I am getting is
What went wrong:
org.gradle.api.tasks.SourceSetOutput.getClassesDir()Ljava/io/File;
Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Exception is:
java.lang.NoSuchMethodError:
org.gradle.api.tasks.SourceSetOutput.getClassesDir()Ljava/io/File;
at org.sonarqube.gradle.SonarQubePlugin.configureSourceDirsAndJavaClasspath(SonarQubePlugin.java:169)
at org.sonarqube.gradle.SonarQubePlugin.lambda$configureForJava$1(SonarQubePlugin.java:104)
I tried downgrading the gradle version to 4.0 and found out the issue, now it is showing
:sonarqube
Gradle now uses separate output directories for each JVM language, but this build assumes a single directory for all classes from a source set. This behaviour has been deprecated and is scheduled to be removed in Gradle 5.0
at org.gradle.api.internal.tasks.DefaultSourceSetOutput.getClassesDir(DefaultSourceSetOutput.java:79)
at org.gradle.api.internal.tasks.DefaultSourceSetOutput_Decorated.getClassesDir(Unknown Source)
at org.sonarqube.gradle.SonarQubePlugin.configureSourceDirsAndJavaClasspath(SonarQubePlugin.java:169)
Gradle configurations present in my code is as below,
sonarqube {
properties {
property "sonar.jacoco.reportPath", "${project.buildDir}/jacoco/test.exec"
property "sonar.exclusions", "**/generated-*/**/*"
property "sonar.sources", "src/main/java"
property "sonar.tests", "src/test/java"
//property "sonar.java.binaries", "${project.buildDir}/classes/main/"
}
}
I believe the issue can be fixed by either adding an expected property to the sonarqube property list or explicitly setting the source directory. Can anyone please advice on how to do that?
I use Gradle 5.1 and I observed the same using org.sonarqube:2.5. However, it works for me when I use org.sonarqube:2.7.
plugins {
id "org.sonarqube" version "2.7"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With