【发布时间】:2016-05-19 09:10:43
【问题描述】:
我有一个 Maven 多模块项目,我使用网站上的 jacoco 示例配置来创建代码覆盖率报告:(http://eclemma.org/jacoco/trunk/doc/examples/build/pom.xml)
所以我的 pom 看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.dti</groupId>
<artifactId>dti-parent</artifactId>
<version>1.0.1</version>
</parent>
<groupId>com.dti.myproject</groupId>
<artifactId>myproject-build-all</artifactId>
<version>6.5.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>myproject</name>
<modules>
<module>../myproject-config</module>
<module>../myproject-messages</module>
<module>../myproject-persistence</module>
<module>../myproject-resources</module>
<module>../myproject-service</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.7-SNAPSHOT</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>
<!-- implementation is needed only for Maven 2 -->
<rule implementation="org.jacoco.maven.RuleConfiguration">
<element>BUNDLE</element>
<limits>
<!-- implementation is needed only for Maven 2 -->
<limit implementation="org.jacoco.report.check.Limit">
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>0.0</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
当我执行 mvn:test 时,肯定会在模块中生成报告,它们看起来很好。但是,当我运行 mvn:verify 时,jacoco 不会创建报告并且控制台输出显示:
[INFO] --- jacoco-maven-plugin:0.7.7-SNAPSHOT:report (default-report) @ myproject-build-all ---
[INFO] Skipping JaCoCo execution due to missing execution data file.
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.7-SNAPSHOT:check (default-check) @ myproject-build-all ---
[INFO] Skipping JaCoCo execution due to missing execution data file:C:\workspaces\release-trunk\myproject-build-all\target\jacoco.exec
有人知道如何解决这个错误吗?
【问题讨论】: