You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Gradle Jacoco聚合插件:如何在任务执行后打印HTML报告路径?

在Gradle构建日志中输出Jacoco聚合报告路径

你可以通过为testCodeCoverageReport任务添加执行完成后的动作,让Gradle自动在构建日志里打印报告的绝对路径。以下是具体配置:

如果你的构建脚本是Kotlin DSL:

plugins {
    id("jacoco-report-aggregation")
}

tasks.named("testCodeCoverageReport") {
    doLast {
        val reportPath = reports.html.outputLocation.get().asFile.toPath().resolve("index.html").toString()
        println("Jacoco聚合测试覆盖率报告已生成,路径:$reportPath")
    }
}

如果你的构建脚本是Groovy DSL:

plugins {
    id("jacoco-report-aggregation")
}

tasks.named('testCodeCoverageReport') {
    doLast {
        def reportPath = reports.html.outputLocation.get().asFile.toPath().resolve('index.html').toString()
        println "Jacoco聚合测试覆盖率报告已生成,路径:$reportPath"
    }
}

配置完成后,执行./gradlew testCodeCoverageReport任务结束时,Gradle会在控制台日志末尾输出报告的完整路径,直接复制即可打开报告文件。

内容的提问来源于stack exchange,提问作者apflieger

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 01:55:32