I have a multi-module maven project, and trying to use Jacoco to generate an aggregated report, and run 'aggregated' checks. However, I cannot in any possible way get the Jacoco merge function to work through the maven plugin. Therefore I tried to create a minimal example, as illustrated below
The project only contains three files, the maven pom file, and two Jacoco exec files (previously generated)
- Root folder
- pom.xml
- jacoco1.exec
- jacoco2.exec
The pom file content looks like the following:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
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.jacoco</groupId>
<version>0.1-SNAPSHOT</version>
<artifactId>coverage</artifactId>
<name>Coverage report</name>
<description>Coverage report module</description>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>merge-results</id>
<phase>verify</phase>
<goals>
<goal>merge</goal>
</goals>
<configuration>
<fileSets>
<fileSet>
<directory>${basedir}/}</directory>
<includes>
<include>*.exec</include> <!-- In the end, I tried a lot of different include options, but nothing seems to work -->
<include>jacoco1.exec</include>
<include>jacoco2.exec</include>
</includes>
</fileSet>
</fileSets>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
When I run mvn verify -X
I get the following debug output under the merge goal:
[DEBUG] Configuring mojo org.jacoco:jacoco-maven-plugin:0.8.6:merge from plugin realm ClassRealm[plugin>org.jacoco:jacoco-maven-plugin:0.8.6, parent: sun.misc.Launcher$AppClassLoader@5c647e05]
[DEBUG] Configuring mojo 'org.jacoco:jacoco-maven-plugin:0.8.6:merge' with basic configurator -->
[DEBUG] (f) destFile = /Users/rsn/git/coverage-mve/coverage/target/jacoco.exec
[DEBUG] (s) directory = /Users/rsn/git/coverage-mve/coverage/}
[DEBUG] (s) includes = [*.exec, jacoco1.exec, jacoco2.exec]
[DEBUG] (f) fileSets = [org.apache.maven.shared.model.fileset.FileSet@56681eaf]
[DEBUG] (f) project = MavenProject: com.jacoco:coverage:0.1-SNAPSHOT @ /Users/rsn/git/coverage-mve/coverage/pom.xml
[DEBUG] (f) skip = false
[DEBUG] -- end configuration --
[INFO] Skipping JaCoCo merge execution due to missing execution data files
Maven version is
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec
Java version: 1.8.0_181, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/jre
Default locale: en_DK, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "Mac"
I tried downloading the jacococli.jar
and merge the files manually with that, which works fine. I guess this could be downloaded and run with the maven ant run plugin as a workaround, but I would prefer just using the plugin!
Any ideas what could cause this issue?
question from:https://stackoverflow.com/questions/65940964/why-is-jacoco-merge-not-including-files