WARN: Could not calculate hash for class XXXX

Ok, so after extending the logging internally and experimenting with a Gradle multi-module build I can definitely say that hash calculation will not work if there are wildcards in sonar.java.binaries.

In general, wildcards are not officially supported for this property: (link)

Furthermore, for Gradle projects, the Sonar Gradle plugin should be used for scanning instead of invoking the standalone scanner via the Jenkins plugin.

How can we move forward to resolve the problems you are experiencing?

I definitely recommend using the SonarScanner for Gradle plugin for scanning. It will automatically fill in sonar.java.binaries correctly. It eliminates the need for wildcards, and you also do not need to maintain the property manually for multiple sub-projects.
Furthermore, you can still use it from within Jenkins!

Here is documentation on how to add the Sonar plugin to your Gradle configuration: SonarScanner for Gradle
And here is information on how to configure and invoke it from within Jenkins: Jenkins extension for SonarQube

Please let me know if you run into any problems when switching to the SonarScanner for Gradle plugin for scanning.

1 Like