gpt4 book ai didi

android - 如何为多模块项目创建汇总的 Jacoco 报告?

转载 作者:行者123 更新时间:2023-12-04 23:44:44 27 4
gpt4 key购买 nike

几天来我一直在寻找合并多个 Jacoco 的解决方案多模块 Android 项目的报告,以便将它们发送到 Sonarcloud立刻。我已经检查了大量 Stackoverflow 帖子和其他内容,例如博客、Github 存储库、Gradle forum等,但不幸的是,没有一个解决方案适合我。
如果有人在这里与我分享示例项目或代码 fragment ,我将不胜感激。

Gradle version: 7.0.2
Kotlin version: 1.5.21
JDK: 11
下面的代码段也不适合我
/**
* Root task that generates an aggregated Jacoco test coverage report for all sub-projects
*/
task jacocoFullReport(type: JacocoReport, group: 'Coverage reports') {
group = 'Reporting'
description = 'Generates an aggregate report from all subprojects'

tasks.withType(Test) {
ignoreFailures true
}

def projects = subprojects

//noinspection GrUnresolvedAccess
dependsOn(projects.jacocoReport)

final source = files(projects.jacocoReport.sourceDirectories)

additionalSourceDirs.setFrom source
sourceDirectories.setFrom source

classDirectories.setFrom files(projects.jacocoReport.classDirectories)
executionData.setFrom files(projects.jacocoReport.executionData)

reports {
html {
enabled true
destination file('build/reports/jacoco/html')
}
csv {
enabled true
destination file('build/reports/jacoco/jacocoFullReport.csv')
}
}

doFirst {
//noinspection GroovyAssignabilityCheck
executionData.setFrom files(executionData.findAll { it.exists() })
}
}

最佳答案

这里的工作示例如何创建聚合的 jacoco 报告:
https://github.com/SurpSG/jacoco-gradle-plugin-merge-coverage

task jacocoRootReport(type: JacocoReport, group: 'Coverage reports') {
description = 'Generates an aggregate report from all subprojects'
dependsOn(subprojects.test)

additionalSourceDirs.from = files(subprojects.sourceSets.main.allSource.srcDirs)
sourceDirectories.from = files(subprojects.sourceSets.main.allSource.srcDirs)
classDirectories.from = files(subprojects.sourceSets.main.output)
executionData.from = files(subprojects.jacocoTestReport.executionData)

reports {
html.enabled true
}
}

关于android - 如何为多模块项目创建汇总的 Jacoco 报告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69498972/

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