This an an archived version of the documentation for SonarQube version 4.5 & 4.5.x LTS.
See for current functionality

Skip to end of metadata
Go to start of metadata
Could not retrieve - Page not found.

Description / Feature

This plugin is included in the Java Ecosystem.

It provides the ability to feed SonarQube with code coverage data coming from JaCoCo (an open source and robust Java code coverage tool, developed by the authors of EclEmma). For more information, see: Comparison of Emma, Clover, Cobertura and JaCoCo.

SonarQube Java Plugin




Reports generated with JaCoCo


To launch JaCoCo as part of your Maven build, use this command: mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Dmaven.test.failure.ignore=true

For more on JaCoCo, see its documentation.

You may also find the of the sample project helpful.

See Code Coverage by Unit Tests for Java Project tutorial.

Using argLine

If your project uses the argLine property to configure the surefire-maven-plugin, be sure that argLine defined as a property, rather than as part of the plugin configuration. Doing so will allow JaCoCo to set its agent properly. Otherwise the JVM may crash while tests are running.

That is, argLine should be defined this way: 


Force coverage to 0% 

By default, when no coverage report is found, the JaCoCo plugin will not set any value for coverage metric. This behaviour can be overriden to force coverage to 0% in case of a lack of report by setting the following property :

Coverage per test 

Using some unit test listeners you can collect the information on which lines where covered by which tests and display them in SonarQube. See  the pom.xml of the sample project to configure this and see the Component Viewer documentation to display this information in SonarQube.


  • No labels