Maven 杰科科的保险不见了
我已经为此工作了几个小时,我在网上找到的每一个解决方案都没有什么不同 我有一个用Kotlin写的项目。我的sonar服务器上安装了Kotlin插件。我正在使用JaCoCo插件为sonar生成代码覆盖率报告 我的项目是多模块的,但只有一个子模块有单元测试,所以我在那里定义了我的JaCoCo插件 我也在使用Surefire插件 以下是我在pom.xml中的属性Maven 杰科科的保险不见了,maven,sonarqube,jacoco,maven-surefire-plugin,jacoco-maven-plugin,Maven,Sonarqube,Jacoco,Maven Surefire Plugin,Jacoco Maven Plugin,我已经为此工作了几个小时,我在网上找到的每一个解决方案都没有什么不同 我有一个用Kotlin写的项目。我的sonar服务器上安装了Kotlin插件。我正在使用JaCoCo插件为sonar生成代码覆盖率报告 我的项目是多模块的,但只有一个子模块有单元测试,所以我在那里定义了我的JaCoCo插件 我也在使用Surefire插件 以下是我在pom.xml中的属性 <properties> <sonar.java.binaries>target/classes</s
<properties>
<sonar.java.binaries>target/classes</sonar.java.binaries>
<sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
<sonar.jacoco.reportPath>target/jacoco.exec</sonar.jacoco.reportPath>
<sonar.language>kotlin</sonar.language>
<sonar.sources>src/main</sonar.sources>
<sonar.tests>src/test</sonar.tests>
<sonar.verbose>true</sonar.verbose>
<sonar.jacoco.reportsPath>target</sonar.jacoco.reportsPath>
<sonar.junit.reportsPath>target/surefire-reports</sonar.junit.reportsPath>
<sonar.surefire.reportsPath>target/surefire-reports</sonar.surefire.reportsPath>
<surefireArgLine/>
</properties>
声纳报告没有覆盖
在某个时间点,我得到了代码覆盖率数据。此时,该项目只是一个模块,可能没有使用surefire(我记不清了)
希望有人能看到我的错误并帮我解决
谢谢,
托尼亚
编辑,添加控制台输出:
tohrel@ussd-olm-016438:~/projects/project-name-redacted/vqs-api$ mvn sonar:sonar -Dsonar.projectName=vqs -Dsonar.projectKey=vqs
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Variant Query Service - API 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- sonar-maven-plugin:3.4.0.905:sonar (default-cli) @ vqs-api ---
[INFO] User cache: /Users/tohrel/.sonar/cache
[INFO] SonarQube version: 7.2.1
[INFO] Default locale: "en_US", source code encoding: "UTF-8"
[INFO] Publish mode
[INFO] Load global settings
[INFO] Load global settings (done) | time=143ms
[INFO] Server id: AWT2VY5OzSeF07PuEM-H
[INFO] User cache: /Users/tohrel/.sonar/cache
[INFO] Load/download plugins
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=82ms
[INFO] Load/download plugins (done) | time=132ms
[INFO] Loaded core extensions:
[INFO] Process project properties
[INFO] Load project repositories
[INFO] Load project repositories (done) | time=140ms
[INFO] Load quality profiles
[INFO] Load quality profiles (done) | time=63ms
[INFO] Load active rules
[INFO] Load active rules (done) | time=618ms
[INFO] Load metrics repository
[INFO] Load metrics repository (done) | time=19ms
[INFO] Project key: vqs
[INFO] Project base dir: /Users/tohrel/projects/project-name-redacted/vqs-api
[INFO] ------------- Scan vqs
[INFO] Load server rules
[INFO] Load server rules (done) | time=178ms
[INFO] Base dir: /Users/tohrel/projects/project-name-redacted/vqs-api
[INFO] Working dir: /Users/tohrel/projects/project-name-redacted/vqs-api/target/sonar
[INFO] Source paths: src/main
[INFO] Test paths: src/test
[INFO] Source encoding: UTF-8, default locale: en_US
[INFO] Language is forced to kotlin
[INFO] Index files
[INFO] 254 files indexed
[INFO] Quality profile for kotlin: Sonar way
[INFO] Sensor Kotlin Sensor [kotlin]
[INFO] 208 source files to be analyzed
[INFO] Sensor Kotlin Sensor [kotlin] (done) | time=2693ms
[INFO] 208/208 source files have been analyzed
[INFO] Sensor SonarJavaXmlFileSensor [java]
[INFO] Sensor SonarJavaXmlFileSensor [java] (done) | time=4ms
[INFO] Sensor Zero Coverage Sensor
[INFO] Sensor Zero Coverage Sensor (done) | time=90ms
[INFO] Sensor CPD Block Indexer
[INFO] Sensor CPD Block Indexer (done) | time=0ms
[INFO] 57 files had no CPD blocks
[INFO] Calculating CPD for 151 files
[INFO] CPD calculation finished
[INFO] Analysis report generated in 484ms, dir size=658 KB
[INFO] Analysis reports compressed in 582ms, zip size=444 KB
[INFO] Analysis report generated in /Users/tohrel/projects/project-name-redacted/vqs-api/target/sonar/scanner-report
[INFO] Analysis report uploaded in 27ms
[INFO] ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard?id=vqs
[INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[INFO] More about the report processing at http://localhost:9000/api/ce/task?id=AWVagYWzPCQMqzjb5q73
[INFO] Task total time: 7.582 s
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.536 s
[INFO] Finished at: 2018-08-20T20:22:42-07:00
[INFO] Final Memory: 56M/869M
[INFO] ------------------------------------------------------------------------
在@Godin的帮助下(非常感谢),我的代码覆盖率正在工作 这可能不是唯一的解决方案,但对我来说是有效的 首先,我从extensions/plugins目录中删除了sonar kotlin官方插件,并添加了以下内容: 其次,我更新了我的属性,这些属性似乎已经过时,与此示例中概述的内容相似: 财产(节选)
${project.build.directory}/jacoco-ut.exec
${project.build.directory}/jacoco-it.exec
科特林
src/main/java
src/test/java
${project.build.directory}/surefire报告
${jacoco.report.ut},${jacoco.report.it}
插件配置为surefire、failsafe和jacoco
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>${surefireArgLine}</argLine>
<excludes>
<exclude>**/*IT.java</exclude>
</excludes>
</configuration>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<argLine>${failsafeArgLine}</argLine>
<includes>
<include>**/*IT.java</include>
</includes>
</configuration>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.1</version>
<executions>
<execution>
<id>jacoco-agent-ut</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${jacoco.report.ut}</destFile>
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>jacoco-agent-it</id>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
<configuration>
<destFile>${jacoco.report.it}</destFile>
<propertyName>failsafeArgLine</propertyName>
</configuration>
</execution>
</executions>
</plugin>
org.apache.maven.plugins
maven surefire插件
${surefireArgLine}
**/*IT.java
org.junit.platform
junit平台surefire提供程序
1.2.0
org.junit.jupiter
朱尼特木星发动机
${junit jupiter.version}
org.apache.maven.plugins
maven故障保护插件
${failsafeArgLine}
**/*IT.java
org.junit.platform
junit平台surefire提供程序
1.2.0
org.junit.jupiter
朱尼特木星发动机
${junit jupiter.version}
org.jacoco
jacocomaven插件
0.8.1
杰科科特工
配制剂
${jacoco.report.ut}
surefireArgLine
杰科科探员
准备代理集成
${jacoco.report.it}
故障保护argline
阅读后,这里的这个问题可能可以删除?谢谢@Godin,我有文件证明它在6月和7月起作用。8月初发生了一些变化,导致它停止工作。在这段时间里,一些事情发生了变化,但我们对Kotlin的使用并不是其中之一。我们从项目开始就一直在使用它。所以我怀疑Kotlin插件中的一个bug是否是原因,因为我们以前看到它在工作。我确实尝试了sonar jacoco插件,该插件在第二个链接中作为修复建议,但是。。。我还尝试使用一个非官方的插件:。仍然没有覆盖率数据。在我的例子中,我认为我还遗漏了一些东西或做错了。首先-sonar.jacoco.reportPath
和sonar.jacoco.reportsPath
(第一个被弃用,第二个被弃用)是Java插件的属性,它不能也不会为Kotlin导入exec
,然而,您通过sonar.language=Kotlin
强制项目的语言为Kotlin。第二-根据sonar.jacoco.reportpath
应该是例如target/jacoco.exec
,而不仅仅是target
。完美现在真的很欣赏细节的魅力。
mvn sonar:sonar -Dsonar.projectName=vqs -Dsonar.projectKey=vqs
tohrel@ussd-olm-016438:~/projects/project-name-redacted/vqs-api$ mvn sonar:sonar -Dsonar.projectName=vqs -Dsonar.projectKey=vqs
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Variant Query Service - API 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- sonar-maven-plugin:3.4.0.905:sonar (default-cli) @ vqs-api ---
[INFO] User cache: /Users/tohrel/.sonar/cache
[INFO] SonarQube version: 7.2.1
[INFO] Default locale: "en_US", source code encoding: "UTF-8"
[INFO] Publish mode
[INFO] Load global settings
[INFO] Load global settings (done) | time=143ms
[INFO] Server id: AWT2VY5OzSeF07PuEM-H
[INFO] User cache: /Users/tohrel/.sonar/cache
[INFO] Load/download plugins
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=82ms
[INFO] Load/download plugins (done) | time=132ms
[INFO] Loaded core extensions:
[INFO] Process project properties
[INFO] Load project repositories
[INFO] Load project repositories (done) | time=140ms
[INFO] Load quality profiles
[INFO] Load quality profiles (done) | time=63ms
[INFO] Load active rules
[INFO] Load active rules (done) | time=618ms
[INFO] Load metrics repository
[INFO] Load metrics repository (done) | time=19ms
[INFO] Project key: vqs
[INFO] Project base dir: /Users/tohrel/projects/project-name-redacted/vqs-api
[INFO] ------------- Scan vqs
[INFO] Load server rules
[INFO] Load server rules (done) | time=178ms
[INFO] Base dir: /Users/tohrel/projects/project-name-redacted/vqs-api
[INFO] Working dir: /Users/tohrel/projects/project-name-redacted/vqs-api/target/sonar
[INFO] Source paths: src/main
[INFO] Test paths: src/test
[INFO] Source encoding: UTF-8, default locale: en_US
[INFO] Language is forced to kotlin
[INFO] Index files
[INFO] 254 files indexed
[INFO] Quality profile for kotlin: Sonar way
[INFO] Sensor Kotlin Sensor [kotlin]
[INFO] 208 source files to be analyzed
[INFO] Sensor Kotlin Sensor [kotlin] (done) | time=2693ms
[INFO] 208/208 source files have been analyzed
[INFO] Sensor SonarJavaXmlFileSensor [java]
[INFO] Sensor SonarJavaXmlFileSensor [java] (done) | time=4ms
[INFO] Sensor Zero Coverage Sensor
[INFO] Sensor Zero Coverage Sensor (done) | time=90ms
[INFO] Sensor CPD Block Indexer
[INFO] Sensor CPD Block Indexer (done) | time=0ms
[INFO] 57 files had no CPD blocks
[INFO] Calculating CPD for 151 files
[INFO] CPD calculation finished
[INFO] Analysis report generated in 484ms, dir size=658 KB
[INFO] Analysis reports compressed in 582ms, zip size=444 KB
[INFO] Analysis report generated in /Users/tohrel/projects/project-name-redacted/vqs-api/target/sonar/scanner-report
[INFO] Analysis report uploaded in 27ms
[INFO] ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard?id=vqs
[INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[INFO] More about the report processing at http://localhost:9000/api/ce/task?id=AWVagYWzPCQMqzjb5q73
[INFO] Task total time: 7.582 s
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.536 s
[INFO] Finished at: 2018-08-20T20:22:42-07:00
[INFO] Final Memory: 56M/869M
[INFO] ------------------------------------------------------------------------
<properties>
<!-- Sonar configuration -->
<jacoco.report.ut>${project.build.directory}/jacoco-ut.exec</jacoco.report.ut>
<jacoco.report.it>${project.build.directory}/jacoco-it.exec</jacoco.report.it>
<sonar.language>kotlin</sonar.language>
<sonar.sources>src/main/java</sonar.sources>
<sonar.tests>src/test/java</sonar.tests>
<sonar.junit.reportPaths>${project.build.directory}/surefire-reports</sonar.junit.reportPaths>
<sonar.jacoco.reportPaths>${jacoco.report.ut},${jacoco.report.it}</sonar.jacoco.reportPaths>
</properties>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>${surefireArgLine}</argLine>
<excludes>
<exclude>**/*IT.java</exclude>
</excludes>
</configuration>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<argLine>${failsafeArgLine}</argLine>
<includes>
<include>**/*IT.java</include>
</includes>
</configuration>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.1</version>
<executions>
<execution>
<id>jacoco-agent-ut</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${jacoco.report.ut}</destFile>
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>jacoco-agent-it</id>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
<configuration>
<destFile>${jacoco.report.it}</destFile>
<propertyName>failsafeArgLine</propertyName>
</configuration>
</execution>
</executions>
</plugin>