0

I would like to add a coverage report in my maven site website in the case of a multi-modules project.

I found how to have an aggregated coverage report in a module created just to for that. see .

But I did not find how to add a coverage report in my maven site website in the case of a multi modules project.

Does someone know to achieve that?

As requested, my parent pom is as follows. The comments in reporting tag are due to some tries to produce the report. I tried several configurations but no one generates the report.

Nothing is defined for coverage in child modules, except in coverage module that contains the generation of the aggregated coverage report.

The version of Maven is 3.8.6, the version of Java is open JDK 19, the version of the surfire plugin is 3.1.2. The version of Jacoco plugin is 0.8.10 .

<!-- parent and artifact defintions -->

<packaging>pom</packaging>

<properties>
    <!-- some properties -->
</properties>

<modules>
    <module>moduleA</module>
    <module>moduleB</module>
    <module>moduleC</module>
    <module>coverage</module>
</modules>

    
<dependencies>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter</artifactId>
        <version>5.10.0</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<distributionManagement>
    <site>
        <id>AAA site</id>
        <url><!-- a path --></url>
    </site>
</distributionManagement>
  
<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-site-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-project-info-reports-plugin</artifactId>
            <version>2.9</version>
            <reportSets>
                <reportSet>
                    <reports>
                        <report>index</report>
                    </reports>
                </reportSet>
            </reportSets>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>3.6.0</version>
            <configuration>
                <show>private</show>
            </configuration>
            <reportSets>
                <reportSet>
                    <id>javadoc</id>
                    <reports>
                        <report>javadoc</report>
                    </reports>
                </reportSet>
                <reportSet>
                    <id>aggregate</id>
                    <inherited>false</inherited>
                    <reports>
                        <report>aggregate</report>
                    </reports>
                </reportSet>
                <reportSet>
                    <id>test-javadoc</id>
                    <reports>
                        <report>test-javadoc</report>
                    </reports>
                </reportSet>
                <reportSet>
                    <id>test-aggregate</id>
                    <inherited>false</inherited>
                    <reports>
                        <report>test-aggregate</report>
                    </reports>
                </reportSet>
            </reportSets>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <version>2.22.2</version>
            <configuration>
                <aggregate>true</aggregate>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <reportSets>
                <!-- <reportSet> -->
                <!-- <id>coverage</id> -->
                <!-- <configuration> -->
                <!-- <dataFileIncludes> -->
                <!-- <dataFileInclude>**/jacoco-unit.exec</dataFileInclude>  -->
                <!-- </dataFileIncludes> -->
                <!-- </configuration>                -->
                <!-- <reports> -->
                <!-- <report>report</report> -->
                <!-- </reports> -->
                <!-- </reportSet> -->
                <reportSet>
                    <id>coverage-aggregate</id>
                    <configuration>
                        <dataFileIncludes>
                            <dataFileInclude>**/target/jacoco-unit.exec</dataFileInclude>
                        </dataFileIncludes>
                    </configuration>
                    <inherited>false</inherited>
                    <reports>
                        <report>report-aggregate</report>
                    </reports>
                </reportSet>
            </reportSets>
        </plugin>
    </plugins>
</reporting>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.1.2</version>
        </plugin>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>${jacoco.version}</version>
            <executions>
                <execution>
                    <id>prepare-agent</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>report</id>
                    <phase>test</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

</project>

Sincerely,

3
  • Do you have an artifact like ear, war or what kind of project do you have? Can you show us some pom files etc. Which Maven version, JDK Version etc.? Commented Oct 16, 2023 at 15:40
  • of course this is jar modules. I edit my question to integrate an example of my pom. Commented Oct 16, 2023 at 15:46
  • I posted my pom, @khmarbaise if you have any ideas I would thank you so much. Commented Oct 16, 2023 at 16:03

1 Answer 1

1

In fact it seems that's not supported. see here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.