Reputation: 904
I have a maven multimodule project and I use the example configuration for jacoco from the website in order to create code coverage reports: (http://eclemma.org/jacoco/trunk/doc/examples/build/pom.xml)
So my pom looks like this:
<?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>
<parent>
<groupId>com.dti</groupId>
<artifactId>dti-parent</artifactId>
<version>1.0.1</version>
</parent>
<groupId>com.dti.myproject</groupId>
<artifactId>myproject-build-all</artifactId>
<version>6.5.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>myproject</name>
<modules>
<module>../myproject-config</module>
<module>../myproject-messages</module>
<module>../myproject-persistence</module>
<module>../myproject-resources</module>
<module>../myproject-service</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.7-SNAPSHOT</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<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>
<!-- implementation is needed only for Maven 2 -->
<rule implementation="org.jacoco.maven.RuleConfiguration">
<element>BUNDLE</element>
<limits>
<!-- implementation is needed only for Maven 2 -->
<limit implementation="org.jacoco.report.check.Limit">
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>0.0</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
When I execute mvn:test the surefire reports are generated within the modules and they look just fine. However, when I run mvn:verify, jacoco does not create a report and the console output displays:
[INFO] --- jacoco-maven-plugin:0.7.7-SNAPSHOT:report (default-report) @ myproject-build-all ---
[INFO] Skipping JaCoCo execution due to missing execution data file.
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.7-SNAPSHOT:check (default-check) @ myproject-build-all ---
[INFO] Skipping JaCoCo execution due to missing execution data file:C:\workspaces\release-trunk\myproject-build-all\target\jacoco.exec
Does anybody know how to fix this error?
Upvotes: 1
Views: 1238
Reputation: 652
<phase>prepare-package</phase>
to <phase>test</phase>
in order for mvn:test to generate the jacoco report (and not only the surefire report).<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>jacoco.agent.ut.arg</propertyName>
</configuration>
</execution>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>${jacoco.agent.ut.arg}</argLine>
</configuration>
</plugin>
Upvotes: 2