多模块项目中的声纳覆盖率始终为 0
Sonar coverage always 0 in multi module project
我正在开发一个结构如下的多模块 maven 项目:
Parent
|----Client
|----Server
|----End2End
服务器是一个 spring 启动应用程序,它产生一个 REST 接口。 Client 是一个使用 REST 接口的简单 swing 应用程序,End2End 是一个包含一些端到端测试的模块 (client/server)。进入真正的问题,这是我在父 pom 中的属性:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<jacoco.data.file>${project.build.directory}/jacoco.exec</jacoco.data.file>
<jacoco.report.path>${project.reporting.outputDirectory}</jacoco.report.path>
<sonar.language>java</sonar.language>
<sonar.jacoco.reportPaths>${project.reporting.outputDirectory}</sonar.jacoco.reportPaths>
</properties>
这是我的构建部分
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
<configuration>
<jacocoReports>
<jacocoReport>${project.reporting.outputDirectory}/jacoco.xml</jacocoReport>
</jacocoReports>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<configuration>
<excludes>
<exclude>**/ServerApplication.*</exclude>
<exclude>**/DatabaseGrid.*</exclude>
<exclude>**/WebSecurityConfig.*</exclude>
<exclude>**/App.*</exclude>
<exclude>**/DatabaseGrid.*</exclude>
<exclude>**/GridFromServer.*</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<!-- binds by default to the phase "initialize" -->
<goal>prepare-agent</goal>
<!-- binds by default to the phase "verify" -->
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
当我启动一个构建时
mvn clean verify coveralls:report
工作服上正确报告了我的总体代码覆盖率。
但是当我启动时:
mvn clean verify sonar:sonar
分析有效,但代码覆盖率始终保持在 0%。我确信我在报告路径中弄错了一些东西,jacoco 报告在 parent/target/jacoco.exec 中。谁能帮帮我?
<sonar.jacoco.reportPaths>${project.reporting.outputDirectory}</sonar.jacoco.reportPaths>
指定目录,而根据SonarQube documentation应该指定exec files.
我正在开发一个结构如下的多模块 maven 项目:
Parent
|----Client
|----Server
|----End2End
服务器是一个 spring 启动应用程序,它产生一个 REST 接口。 Client 是一个使用 REST 接口的简单 swing 应用程序,End2End 是一个包含一些端到端测试的模块 (client/server)。进入真正的问题,这是我在父 pom 中的属性:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<jacoco.data.file>${project.build.directory}/jacoco.exec</jacoco.data.file>
<jacoco.report.path>${project.reporting.outputDirectory}</jacoco.report.path>
<sonar.language>java</sonar.language>
<sonar.jacoco.reportPaths>${project.reporting.outputDirectory}</sonar.jacoco.reportPaths>
</properties>
这是我的构建部分
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
<configuration>
<jacocoReports>
<jacocoReport>${project.reporting.outputDirectory}/jacoco.xml</jacocoReport>
</jacocoReports>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<configuration>
<excludes>
<exclude>**/ServerApplication.*</exclude>
<exclude>**/DatabaseGrid.*</exclude>
<exclude>**/WebSecurityConfig.*</exclude>
<exclude>**/App.*</exclude>
<exclude>**/DatabaseGrid.*</exclude>
<exclude>**/GridFromServer.*</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<!-- binds by default to the phase "initialize" -->
<goal>prepare-agent</goal>
<!-- binds by default to the phase "verify" -->
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
当我启动一个构建时
mvn clean verify coveralls:report
工作服上正确报告了我的总体代码覆盖率。 但是当我启动时:
mvn clean verify sonar:sonar
分析有效,但代码覆盖率始终保持在 0%。我确信我在报告路径中弄错了一些东西,jacoco 报告在 parent/target/jacoco.exec 中。谁能帮帮我?
<sonar.jacoco.reportPaths>${project.reporting.outputDirectory}</sonar.jacoco.reportPaths>
指定目录,而根据SonarQube documentation应该指定exec files.