gpt4 book ai didi

gradle - 如何在 Gradle 中为多模块项目聚合 Sonar 报告?

转载 作者:行者123 更新时间:2023-12-03 05:46:55 33 4
gpt4 key购买 nike

我有一个多模块 Gradle 4.6 项目和 Sonarqube 7。Sonarqube 和 Jacoco 配置如下:

apply plugin: 'org.sonarqube'

sonarqube {
properties {
property 'sonar.host.url', sonarHostUrl
property 'sonar.jacoco.reportPaths', "$buildDir/reports/jacoco"
}
}

apply plugin: 'jacoco'

jacoco {
toolVersion = "0.7.9"
}

jacocoTestReport {
group = "Reporting"
reports {
xml.enabled true
xml.destination "${buildDir}/reports/jacoco/report.xml"
csv.enabled false
html.enabled true
}
}

test {
jacoco {
append = true
}
}

我正在使用以下命令运行构建和 Sonar :
./gradlew clean build jacocoTestReport --info

./gradlew sonarqube -Dsonar.branch=nonMasterBranch --info

我希望它能够汇总 Sonar 报告并向我展示 Sonarqube 中的单个项目(我在 jacoco 配置中使用 append=true)。但是,我每个模块都有一个非常困惑的项目。

非常感谢您的任何想法!我已经为这个 hell 任务工作了太多时间并且没有任何想法:C

最佳答案

根据this answer , 你应该试试 Jacoco Coverage Gradle Plugin

只需将其添加到您的根项目中:

buildscript {
repositories {
jcenter()
}

dependencies {
classpath 'com.palantir:jacoco-coverage:0.4.0'
}
}

apply plugin: 'com.palantir.jacoco-full-report'

根据文档:

The com.palantir.jacoco-full-report plugin adds a task that produces a Jacoco report for the combined code coverage of the tests of all subprojects of the current project.

关于gradle - 如何在 Gradle 中为多模块项目聚合 Sonar 报告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49575949/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com