站点中未生成 Jacoco 报告

Jacoco Report are not generated in the site

当 mvn 构建站点时,不会生成 Jacoco 报告。

Jacoco 报告在我位于 target\site\jacoco 的目标文件夹中生成,但不知何故,当我尝试构建 jar 站点时,我无法在 "Project Reports" 下看到 "Jacoco Tests" 选项

我在生成站点时在日志中看到的唯一内容如下:

[INFO] <<< clirr-maven-plugin:2.6.1:clirr @ data-binding <<< 
[INFO] configuring report plugin com.cerner.engineering:maven-cerner-ml-dependency-plugin:1.1.1 
[INFO] configuring report plugin org.jacoco:jacoco-maven-plugin:0.7.4.201502262128
[INFO] Skipping JaCoCo execution due to missing execution data file:C:\MSVCWorkspace\br-hla-april-data-binding\target\jacoco.exec

我正在使用命令 mvn clean install site

这就是我在构建部分的 pom.xml 中配置 jacoco 的方式:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${surefire.plugin.version}</version>
            <configuration>
               <excludes>
                  <exclude>**/*Suite*.java</exclude>
               </excludes>
               <forkCount>1</forkCount>
               <reuseForks>false</reuseForks>
               <argLine>-Xms64m -Xmx512m -XX:MaxPermSize=256M -enableassertions -XX:+HeapDumpOnOutOfMemoryError ${jacoco.argLine}</argLine>
               <junitArtifactName>junit:junit-dep</junitArtifactName>
            </configuration>
         </plugin>

Jacoco 插件的名称如下:

<plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>${jacoco.version}</version>
            <configuration>
                <destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile>
                <dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>
            </configuration>
            <executions>
                <execution>
                    <id>jacoco-initialize</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <propertyName>jacoco.argLine</propertyName>
                        </configuration>
                </execution>
                <execution>
                    <id>jacoco-site</id>
                    <phase>package</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

我不确定是什么导致了这个问题,而不是在我的网站上生成 Jacoco 报告。

尽管我可以在我的日志中看到以下内容

[INFO] 
[INFO] --- jacoco-maven-plugin:0.7.4.201502262128:prepare-agent (default-cli) @ data-binding ---

[INFO] argLine set to -javaagent:C:\_repository\org\jacoco\org.jacoco.agent\0.7.4.201502262128\org.jacoco.agent-0.7.4.201502262128-runtime.jar=destfile=C:\target\coverage-reports\jacoco-unit.exec

谢谢!!!

我可以通过如下调用插件来修复

<plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>${jacoco.version}</version>
            <configuration>
                <dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>
            </configuration>
            <executions>
                <execution>
                    <id>jacoco-initialize</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <propertyName>jacoco.argLine</propertyName>
                        </configuration>
                </execution>
            </executions>
        </plugin>