Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
145 views
in Technique[技术] by (71.8m points)

java - Why is Jacoco merge not including files?

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your

<fileSet>
  <directory>${basedir}/}</directory>

looks suspicious - note trailing curly brace, which is probably interpreted as directory name.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...