过滤Lombok,Gradle,Jacoco和Sonar的报道 [英] Filtering coverage with Lombok, Gradle, Jacoco and Sonar

查看:930
本文介绍了过滤Lombok,Gradle,Jacoco和Sonar的报道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JaCoCo 0.8.0的Java项目中使用Gradle 4.4,SonarJava 5.0.1使用Sonar。

我有一个课程用lombok的 @Value @Builder



我的JaCoCo配置build.gradle看起来像这样:

  jacoco {
toolVersion =0.8.0
reportsDir =文件($ buildDir / reports / jacoco)
}

jacocoTestReport.doFirst {
classDirectories = files(buildDir / classes)
}

任务jacocoReport(类型:JacocoReport){
sourceSets sourceSets.main
executionData测试,integrationTest
}

另外,我有lombok.confi文件,属性 lombok.addLombokGeneratedAnnotation = true ,生成的东西实际上有 @ lombok.Generated 在build / classes中注释。



然而,Sonar的覆盖率仍然很低。它报告了大量的条件和行。 正如发布JaCoCo 0.8.0版的公告 b
$ b


请注意

直接读取exec文件(不是最终报告)并嵌入JaCoCo以生成报告的工具将仅提供过滤功能在他们更新到JaCoCo的这个版本之后。所以请关注/ wait / etc各自的供应商,比如
SonarQube - https://jira.sonarsource.com/browse/SONARJAVA-2608



由我们(Ant任务,Maven插件和命令行界面)作为JaCoCo项目的一部分开发的相应集成版本(0.8.0)生成的报告提供了过滤功能



使用Gradle JaCoCo插件,您可以使用toolVersion选择JaCoCoReport任务的运行时和版本 - https://docs.gradle.org/current/userguide/jacoco_plugin.html




这也在 JaCoCo更新日志
$ b


注意:直接读取exec文件并为此嵌入JaCoCo的工具(例如 SonarQube


截至今日(2018年1月29日)为止,修复 https://jira.sonarsource.com/browse/SONARJAVA-2608 应该是尚未发布的SonarJava插件5.1版本。



以上所有内容:由Gradle生成的报告应该已被过滤,由SonarQube生成的报告将在SonarJava升级后被过滤。


I'm using Gradle 4.4 on my Java project with JaCoCo 0.8.0, and Sonar with SonarJava 5.0.1.

I have a class annotated with lombok's @Value and @Builder.

My JaCoCo config in build.gradle looks like this:

jacoco {
    toolVersion = "0.8.0"
    reportsDir = file("$buildDir/reports/jacoco")
}

jacocoTestReport.doFirst{
    classDirectories = files("buildDir/classes")
}

task jacocoReport(type: JacocoReport){
    sourceSets sourceSets.main
    executionData test, integrationTest
}

Also, I have lombok.confi file, with property lombok.addLombokGeneratedAnnotation = true, and generated stuff does actually have @lombok.Generated annotation in build/classes.

However, the coverage on Sonar is still low. It reports a ton of conditions and lines to cover.

解决方案

As stated in announcement of release of JaCoCo version 0.8.0:

Please Note

Tools that directly read exec files (which is not a final report) and embed JaCoCo for generation of report will provide filtering functionality only after they updated to this version of JaCoCo.

So please follow/wait/etc respective vendors such as SonarQube - https://jira.sonarsource.com/browse/SONARJAVA-2608

Reports generated by corresponding version (0.8.0) of integrations developed as part of JaCoCo project by us (Ant Tasks, Maven Plugin and Command Line Interface) provide filtering functionality.

With Gradle JaCoCo Plugin you can select both runtime and version for "JaCoCoReport" task using "toolVersion" - https://docs.gradle.org/current/userguide/jacoco_plugin.html

This is also stated in JaCoCo changelog:

Note: Tools that directly read exec files and embed JaCoCo for this (such as SonarQube or Jenkins) will provide filtering functionality only after they updated to this version of JaCoCo.

As of today (29 Jan 2018) fix for https://jira.sonarsource.com/browse/SONARJAVA-2608 is supposed to be in not yet released SonarJava plugin version 5.1.

From all the above: report generated by Gradle should already be filtered, report generated by SonarQube will be filtered after upgrade of SonarJava.

这篇关于过滤Lombok,Gradle,Jacoco和Sonar的报道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆