Display Coverage Report Without Importing Java Sources

Must-share information (formatted with Markdown):

  • SonarQube version:
  • Scanner version:
  • View results of code coverage report without importing Java source files
  • Uploaded XML Report generated by Jacoco without importing sources, results in ‘0%’ coverage

I am currently trying to view XML coverage reports generated by Jacoco on SonarQube but am running into an issue with satisfying the sonar.sources property of the Sonar Scanner.

I understand that this property is necessary for offering features such as line highlighting, but the issue is my team works on several releases of source code and it becomes impractical to have the source files downloaded to the correct project directory. Further, since Jacoco generates XML reports using .exec data, inaccurate coverage percentages may be displayed if the release of the source files imported to Sonar differ from the class files Jacoco used during report generation.

Hence, I was wondering if there was any way to view coverage metrics included in Jacoco’s reports without importing source files. For example, the html report generated by Jacoco will display a coverage percentage even if source files are not provided. My team is willing to not leverage the Code portion of the Project menu as we find the actual SonarQube dashboard very useful. Thank you.

Hey there.

This is not possible – you have to analyze your source files.

I think you’re missing the big picture – it’s nice that SonarQube can import code coverage reports, but that’s more or less an “extra” feature. SonarQube analyzes your code for bugs, vulnerabilities, and code smells.

If you’re just looking for something to display code coverage… you probably want to stick to the JaCoCo HTML report.

You can find more details about analyzing your Java code in the documetation for the SonarScanner for Gradle and SonarScanner for Maven.