我想jacoco maven plugin用于在使用'check'目标的构建过程中检查代码覆盖的最低级别。
对于单模块项目,一切正常。但是对于多模块,我想检查所有模块的平均代码覆盖率,但是check目标要分别检查每个模块。
例如,module1具有70%的代码覆盖率,module2具有100%的代码覆盖率,两个模块中所有行的平均代码覆盖率为85%。而且我正在尝试将所有项目的代码覆盖率设置为80%,但是由于第一个模块,它失败了。
从pom:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.6.201602180812</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>0.80</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)