java - 无法通过聚合所有模块来生成覆盖率报告

标签 java maven jacoco jacoco-maven-plugin

错误:

[ERROR] Failed to execute goal org.jacoco:jacoco-maven-plugin:0.8.5:report-aggregate (report-aggregate) on project distribution: Unable to parse configuration of mojo org.jacoco:jacoco-maven-plugin:0.8.5:report-aggregate for parameter dataFileIncludes: Cannot assign configuration entry 'dataFileIncludes' with value '**/jacoco-unit.exec' of type java.lang.String to property of type java.util.List -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.

pom.xml

          <plugin>
               <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.2</version>
                <executions>
                    <execution>
                        <id>report-aggregate</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report-aggregate</goal>
                        </goals>
                        <configuration>
                            <dataFileIncludes>**/jacoco-unit.exec</dataFileIncludes>
                            <outputDirectory>${project.reporting.outputDirectory}/jacoco-aggregate</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

我无法聚合所有模块并生成单个代码覆盖率报告

有人遇到过这个问题吗? pom.xml 有什么问题?

最佳答案

错误表明 dataFileIncludes 应该是一个列表。 这也是defined在 jacoco maven 插件源代码中。

所以你可以尝试按照 this document 将其映射到列表中:

          <plugin>
           <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.8.2</version>
            <executions>
                <execution>
                    <id>report-aggregate</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>report-aggregate</goal>
                    </goals>
                    <configuration>
                        <dataFileIncludes>
                           <dataFileInclude>**/jacoco-unit.exec</dataFileInclude> 
                        </dataFileIncludes>
                        <outputDirectory>${project.reporting.outputDirectory}/jacoco-aggregate</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>

关于java - 无法通过聚合所有模块来生成覆盖率报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58729531/

相关文章:

gradle - CorDapp JaCoCo代码覆盖率

java - 自定义对话框 onClickListener

java - mvn Sonar :sonar throwing error

java - Maven 项目无法识别某些 Artifact

java - Intellij Idea 编译器重新编译已编译的项目

JaCoCo 推出 Android Coverage

java - Jacoco gradle 多模块

java - 当我构建字符串时,Java 中的字符常量无效?

java - 找不到 taskdef ant 任务

java - Maven/Eclipse 中的二进制库依赖项