I have configured jacoco plugin as follows. And my project structure as below. There is a parent pom and two modules as core and tests. core contains all the source files. tests contains the test cases.
parent --> core
--> tests
I can see that, jacoco.exec file contain some data. Any idea whats went wrong here?.. Is this because source is in another module?.
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<!--<dataFile>target/jacoco.exec</dataFile>-->
<includes>
<include>org.sample*</include>
</includes>
</configuration>
</execution>
<execution>
<configuration>
<includes>
<include>org.sample*</include>
</includes>
<dataFile>target/jacoco.exec</dataFile>
</configuration>
<id>default-report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
Regards,
Aruna
By the way my test cases are running in a pax-exam container. Is this an issue?.
Yeah, That was the case. I solved the problem using the ant task approach.
Following is the plugin details. I am putting for future reference.
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>${version.maven.antrunplugin}</version>
<executions>
<execution>
<phase>prepare-package</phase>
<configuration>
<target xmlns:jacoco="antlib:org.jacoco.ant">
//this task is to provide class/src files locations for jacoco report generation
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="${project.build.directory}"/>
</taskdef>
<jacoco:report>
<executiondata>
<file file="${project.build.directory}/jacoco.exec"/>
</executiondata>
<structure name="Sample Tests">
<classfiles>
<fileset dir="../core/target/classes"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="../core/src"/>
</sourcefiles>
</structure>
<html destdir="${project.build.directory}/site/jacoco"/>
</jacoco:report>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.ant</artifactId>
<version>${version.org.jacoco.ant}</version>
</dependency>
</dependencies>
</plugin>