Below is a simple pom.xml that demonstrates that the Maven JaCoCo plugin is not compatible with the Surefire plugin when the surefire forkMode (or forkCount / reuseFork) flags are used.
This is a problem for us because our unit tests are running out of PermGen and changing the fork mode can solve this problem for us, but then Sonar doesn't work because of this incompatibility.
We always get the error message:
[ERROR] Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.15:test failed: java.lang.Error: Unable to access JaCoCo Agent - make sure that you use JaCoCo and version not lower than 0.6.2.; nested exception is java.lang.Error: Unable to access JaCoCo Agent - make sure that you use JaCoCo and version not lower than 0.6.2. org/jacoco/agent/rt/RT: org.jacoco.agent.rt.RT -> [Help 1]
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxxxx</groupId>
<artifactId>xxxxx</artifactId>
<version>1.0.0</version>
<properties>
<buildType>Placeholder</buildType>
<isRelease>true</isRelease>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sonar.language>java</sonar.language>
<!-- Tells Sonar to run the unit tests -->
<sonar.dynamicAnalysis>true</sonar.dynamicAnalysis>
<!-- Tells Sonar to use JaCoCo as the code coverage tool -->
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
</properties>
<build>
<plugins>
<!-- junit plugin config -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
<configuration>
<forkMode>always</forkMode>
<!--<argLine>-XX:MaxPermSize=1024m ${argLine}</argLine>-->
<properties>
<property>
<name>listener</name>
<value>org.sonar.java.jacoco.JUnitListener</value>
</property>
</properties>
</configuration>
</plugin>
<!-- for Sonar -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.3.201306030806</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>check</id>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.codehaus.sonar-plugins.java</groupId>
<artifactId>sonar-jacoco-listeners</artifactId>
<version>1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
I have the issue, but I don't get what would be the link with sonarqube ? This error happens only with surefire and jacoco and nothing sonar related...
...
<dependencies>
...
<dependency>
<groupId>org.codehaus.sonar-plugins.java</groupId>
<artifactId>sonar-jacoco-listeners</artifactId>
<version>2.2.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<executions>
<execution>
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<reuseForks>false</reuseForks>
<excludes>
<exclude>**/com/mycom/xxx/test/jms/*</exclude>
</excludes>
<argLine>${jacoco.agent.ut.arg}</argLine>
<properties>
<property>
<name>listener</name>
<value>org.sonar.java.jacoco.JUnitListener</value>
</property>
</properties>
</configuration>
</execution>
</executions>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<reuseForks>false</reuseForks>
<excludes>
<exclude>**/com/mycom/etl/test/jms/*</exclude>
</excludes>
<argLine>${jacoco.agent.ut.arg}</argLine>
<properties>
<property>
<name>listener</name>
<value>org.sonar.java.jacoco.JUnitListener</value>
</property>
</properties>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.1.201405082137</version>
<executions>
<execution>
<id>prepare-ut-agent</id>
<phase>process-test-classes</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>/home/xxx/dev/src/kernel/04.02/fflayer/target/jacoco.exec</destFile>
<propertyName>jacoco.agent.ut.arg</propertyName>
<append>true</append>
</configuration>
</execution>
<execution>
<id>prepare-it-agent</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>/home/xxx/dev/src/kernel/04.02/fflayer/target/jacoco-it.exec</destFile>
<propertyName>jacoco.agent.it.arg</propertyName>
<append>true</append>
</configuration>
</execution>
</executions>
</plugin>
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 33.973s
[INFO] Finished at: Mon Jun 23 14:45:37 CEST 2014
[INFO] Final Memory: 22M/146M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project xxx: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test failed: org.sonar.java.jacoco.JacocoController$JacocoControllerError: Unable to access JaCoCo Agent - make sure that you use JaCoCo and version not lower than 0.6.2. org/jacoco/agent/rt/RT: org.jacoco.agent.rt.RT -> [Help 1]
[INFO] --- jacoco-maven-plugin:0.7.1.201405082137:prepare-agent (prepare-ut-agent) @ fflayer ---
[INFO] jacoco.agent.ut.arg set to -javaagent:/home/xxx/.m2/repository/org/jacoco/org.jacoco.agent/0.7.1.201405082137/org.jacoco.agent-0.7.1.201405082137-runtime.jar=destfile=/home/gle_dromaguet/dev/src/kernel/04.02/fflayer/target/jacoco.exec,append=true
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ fflayer ---
[INFO] Surefire report directory: /home/gle_dromaguet/dev/src/kernel/04.02/fflayer/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running dil.flatfile2.FlatFileSetNameProviderTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.122 sec - in dil.flatfile2.FlatFileSetNameProviderTest
Running dil.flatfile2.FlatFileMappingTimePeriodTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.247 sec - in dil.flatfile2.FlatFileMappingTimePeriodTest
...
--
You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/NlOKWfXD6sA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and all its topics, send an email to jacoco+un...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.