Multi Module Jacoco Report check not working on aggregated report level

125 views
Skip to first unread message

Sameer Kumar

unread,
Aug 30, 2024, 3:21:20 AM8/30/24
to JaCoCo and EclEmma Users
I am looking for a solution to use jacoco:check in a multi module maven project.
The requirement is to put a threshold of 80% coverage check on the entire application instead of individual module.

Right now, it fails the build even if the check for one module is not above the threshold value. I have already created a separate jacoco-aggregate-module where I am aggregating the multi module results.

Configuration of jacoco in parent pom.xml:
<plugin>
  <groupId>org.jacoco</groupId>
  <artifactId>jacoco-maven-plugin</artifactId>
  <version>${jacoco-maven-plugin.version}</version>
  <executions>
  <!-- Prepare the JaCoCo agent before tests run -->
    <execution>
      <id>prepare-agent</id>
      <goals>
        <goal>prepare-agent</goal>
      </goals>
      <phase>initialize</phase>
    </execution>
  </executions>
</plugin>

Configuration of jacoco in jacoco-aggregate-module pom.xml:
<plugin>
  <groupId>org.jacoco</groupId>
  <artifactId>jacoco-maven-plugin</artifactId>
  <version>${jacoco-maven-plugin.version}</version>
  <executions>
  <!-- Aggregate the report after tests run -->
    <execution>
      <id>report-aggregate</id>
      <phase>verify</phase>
      <goals>
        <goal>report-aggregate</goal>
      </goals>
      <configuration>
      <destFile>${project.basedir}/target/jacoco.exec</destFile>
      <outputDirectory>${project.basedir}/target/jacoco-reports</outputDirectory>
      </configuration>
    </execution>
  <execution>
  <id>default-check</id>
  <phase>verify</phase>
  <goals>
    <goal>check</goal>
  </goals>
  <configuration>
    <rules>
      <rule>implementation="org.jacoco.maven.RuleConfiguration">
        <element>BUNDLE</element>
        <limits>
          <limit implementation="org.jacoco.report.check.Limit">
          <counter>LINE</counter>
          <value>COVEREDRATIO</value>
          <minimum>${cc.code-coverage-ratio}</minimum>
          </limit>
        </limits>
      </rule>
     </rules>
    </configuration>
  </execution>
 </executions>
</plugin>

Marc Hoffmann

unread,
Aug 30, 2024, 3:28:39 AM8/30/24
to JaCoCo and EclEmma Users
Dear Sameer,

unfortunately we don’t have a check goal for aggregate reports.

A common work around is to use the JaCoCo Ant tasks (which can be embedded in a Maven build). Unlike the Maven goals the Ant tasks do not make any assumptions about the project layout and can be manually configured according to your needs.

Regards,
-marc

--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/9eaeccf9-a2f0-479d-a4a5-9242562b09acn%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages