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>

-- 
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+unsubscr...@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 via email to