无法生成 jacoco.exec 文件



我有一个带有Mockito和TestNG测试的项目。我想看看Sonarqube的报道。为此,我应该有jacoco.exec文件。当我试图构建我的项目时,结果我得到了";构建成功";目标文件夹中没有jacoco.exec文件。

这是我pom.xml文件的一部分。

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<goals>
<goal>report-aggregate</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
...

开始构建的命令:

mvn clean install sonar:sonar   -Dsonar.projectKey=number20   -Dsonar.host.url=http://localhost:9000   -Dsonar.login=**mylogin**

您的配置没有报告执行目标,除此之外,您不应该使用jacoco-exec文件,因为它已被弃用。您应该按照这个官方示例中的建议配置sonarjacoco插件。

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

然后,在默认路径中生成的jacoco报告将由声纳导入。

最新更新