Search code examples
javamavenjacocojacoco-maven-plugin

Couldn't generate coverage report by aggregating all the modules


Error:

[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>

I couldn't aggregate all modules and generate a single code coverage report.

Did anyone face this issue? what's wrong in the pom.xml?


Solution

  • The error says that the dataFileIncludes is supposed to be a list. This is also defined in jacoco maven plugin source code.

    So you can try to map it to the list by following 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>