maven - Maven Sonarqube Jacoco 0 覆盖
问题描述
我有一个多模块 maven 项目,当我进入 Sonarqube 时看到 0% 的覆盖率,但是当我查看 Jacoco 报告时看到正确的覆盖率{module}/target/site/index.html
这是我的 pom.xml 的相关部分
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.7.201606060606</version>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
这是我的sonar-project.properties
文件
## Sonar Scanner Settings File
# SonarQube info
sonar.host.url=xxx
# Project config
sonar.language=java
sonar.projectKey=project
sonar.projectName=project
sonar.projectVersion=1.0-SNAPSHOT
sonar.github.repository=lendup/project
sonar.sources=module1/src/main/java,module2/src/main/java
sonar.tests=module1/src/test/java,module2/src/test/java
sonar.sourceEncoding=UTF-8
# Test Reports
sonar.junit.reportPaths=module1/target/surefire-reports,module2/target/surefire-reports
sonar.jacoco.reportPaths=module1/target/jacoco.exec,module2/target/jacoco.exec
## Java
sonar.java.binaries=module1/target/classes,module2/target/classes
sonar.java.source=1.8
我的项目不使用 maven surefire 插件,而是手动安装到本地 repo 中,例如
mvn install:install-file -Dfile=assets/surefire-junit4-2.17.jar -DgroupId=org.apache.maven.surefire -DartifactId=surefire-junit4 -Dversion=2.17 -Dpackaging=jar -DgeneratePom=true -DcreateChecksum=true
解决方案
推荐阅读
- html - 带有嵌套元素的 CSS 粘性位置
- javascript - 传单:同一页面上的多个地图
- python - 使用字典、RobotFramework 时 Evaluate 和 SetVariable 之间的区别
- java - Spring Boot:@TestPropertySource 未从导入的配置中加载
- blockchain - 无法从智能合约获取客户端的状态变量
- c# - 从方法返回一个 List<>
- android-dialog - 如何删除 DatePickerDialog 后面不必要的视图?
- c# - 每次调用时都会实例化静态列表
- shell - 如何将值从 jython 脚本返回到 shell 脚本?
- angular - Angular rxjs6我无法回应我想要的..采取并映射