Skip to end of metadata
Go to start of metadata

To execute JaCoCo as part of your Maven build in order to generate the binary format of JaCoCo, use this command: 

mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Dmaven.test.failure.ignore=false

For more details on JaCoCo, see its documentation. You can also play with this sample project.

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: 

	  <properties>
        <argLine>-Xmx128m</argLine>
      </properties>
...
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <runOrder>random</runOrder>
        </configuration>
      </plugin>

Know Old Issue

There is a known issue on version 0.7.3 of JaCoCo agent producing binary reports incompatible with JaCoCo analyzer 0.7.2 embedded in SonarJava.

This issue is fixed with version 0.7.4+ of the agent, so please prefer this version.

SonarJava is compatible with JaCoCo 0.7.5 starting from SonarJava 3.4.

  • No labels