When SonarQube analyzes my Java project which is built using Gradle and Jenkins, I get a lot of warnings about third party libraries not being accessible through the ClassLo
The following fixed this issue for me in build.gradle
sonarqube {
properties {
def compileDependencies = project.configurations.compile.files.collect {it.path}join(",")
def compileOnlyDependencies = project.configurations.compileOnly.files.collect {it.path}join(",")
property "sonar.java.libraries", "$compileDependencies,$compileOnlyDependencies"
property "sonar.test.libraries", "$compileDependencies,$compileOnlyDependencies"
}
}
You'll have to set sonar.libraries
. But in order to set this property manually, you'll have to define a Gradle task that copies all external dependencies to a lib directory, and then use sonar.libraries=path/to/lib/*.jar
to reference them. Instead, I'd invoke Sonar via the sonar-runner
Gradle plugin, which will take care of setting the above properties (plus sonar.libraries
and others) for you.