Hi,
Tl:DR
Property ‘sonar.test.inclusions’ is not supported in Sonar Gradle plugin due to failure
Execution failed for task ':sonar'.
> Could not get unknown property 'sonar.test.inclusions' for project ':server' of type org.gradle.api.Project.
Details
as a SonarQube Enterprise user, we are developing a custom Gradle plugin as a wrapper to auto-configure your Sonar Gradle plugin with our company conventions. We are based on org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:6.2.0.5505.
We are able to scan Java projects and configure sonar properties just fine, but for Golang we need to provide more properties to configure the scope of the analysis.
What we need
We need to auto-configure the scoping of analysis and tests via our Gradle plugin, which works for most properties but fails for sonar.test.inclusions
build.gradle
sonar {
properties {
property "sonar.sources", "."
property "sonar.exclusions", "**/vendor/**,**/testdata/*"
property "sonar.tests", "."
property "sonar.go.coverage.reportPaths", project.layout.buildDirectory.file("reports/go/coverage.out").get().asFile.absolutePath
// This is the only property that can't be set here. Other pass just fine.
property "sonar.test.inclusions" "**/*_test.go"
}
}
The error we get is
Execution failed for task ':sonar'.
> Could not get unknown property 'sonar.test.inclusions' for project ':server' of type org.gradle.api.Project.
Workaround
Setting the value as system property works.
gradle.properties
systemProp.sonar.test.inclusions=**/*_test.go
build.gradle
sonar {
properties {
property "sonar.sources", "."
property "sonar.exclusions", "**/vendor/**,**/testdata/*"
property "sonar.tests", "."
property "sonar.go.coverage.reportPaths", project.layout.buildDirectory.file("reports/go/coverage.out").get().asFile.absolutePath
}
}
This results in a successful scan with the correct _test.go files marked as tests without coverage.
Can you please fix the missing property in the Gradle plugin so we can easily onboard all non-JVM languages? Thank you!