testReport destinationDir 在 gradle 7.4.2 中已弃用,那么如何设置它?

发布于 2025-01-19 07:06:15 字数 768 浏览 0 评论 0原文

task<TestReport>("testReport") {
    destinationDir = file("$buildDir/reports/allTests")
}

这显然已被弃用,但在这种情况下,弃用消息对我来说没有意义。我现在应该如何设置这个值?

    /**
     * Sets the directory to write the HTML report to.
     *
     * <strong>This method will be {@code @Deprecated} soon, please use {@link #getTestResults()} instead to access the new collection property.</strong>
     */
    public void setDestinationDir(File destinationDir) {
        DeprecationLogger.deprecateProperty(TestReport.class, "destinationDir").replaceWith("destinationDirectory")
            .willBeRemovedInGradle8()
            .withDslReference()
            .nagUser();
        getDestinationDirectory().set(destinationDir);
    }
task<TestReport>("testReport") {
    destinationDir = file("$buildDir/reports/allTests")
}

This is apparently deprecated, but the deprecation message doesn't make sense to me in this context. How am I actually supposed to set this value now?

    /**
     * Sets the directory to write the HTML report to.
     *
     * <strong>This method will be {@code @Deprecated} soon, please use {@link #getTestResults()} instead to access the new collection property.</strong>
     */
    public void setDestinationDir(File destinationDir) {
        DeprecationLogger.deprecateProperty(TestReport.class, "destinationDir").replaceWith("destinationDirectory")
            .willBeRemovedInGradle8()
            .withDslReference()
            .nagUser();
        getDestinationDirectory().set(destinationDir);
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

当爱已成负担 2025-01-26 07:06:16

$buildDir 也已被弃用,但好消息是您可以使用 test-report-aggregation 插件收集所有子项目的测试报告。

在 Gradle 8.5 中,我从父 build.gradle 中删除了以下代码片段:

task testReport(type: TestReport) {
    destinationDir = file("./reports/allTests")
    // Include the results from the `test` task in all subprojects
    reportOn subprojects*.test
}

并创建了一个单独的子项目,例如 test-results,其中包含以下 build .gradle

plugins {
     id 'base'
     id 'test-report-aggregation'
}

dependencies {
     testReportAggregation project(':subprojectA')
     testReportAggregation project(':subprojectB')
     testReportAggregation project(':subprojectN')
}

reporting.baseDir = "../reports/allTests"

test.finalizedBy('testAggregateTestReport')

run.enabled = false

$buildDir has also been deprecated but the good news is that you can collect all your subproject's test reports using test-report-aggregation plugin.

In Gradle 8.5, I've removed the following snippet from my parent build.gradle:

task testReport(type: TestReport) {
    destinationDir = file("./reports/allTests")
    // Include the results from the `test` task in all subprojects
    reportOn subprojects*.test
}

and created a separate subproject, say test-results, with the following build.gradle:

plugins {
     id 'base'
     id 'test-report-aggregation'
}

dependencies {
     testReportAggregation project(':subprojectA')
     testReportAggregation project(':subprojectB')
     testReportAggregation project(':subprojectN')
}

reporting.baseDir = "../reports/allTests"

test.finalizedBy('testAggregateTestReport')

run.enabled = false
待"谢繁草 2025-01-26 07:06:15

请这样尝试。

较旧版本:

destinationDir = file("$buildDir/reports/tests/test")

最新版本:

getDestinationDirectory().set(file("$buildDir/reports/tests/test"))

它对我有用。希望它对您有用。谢谢

Please try like this.

Older version:

destinationDir = file("$buildDir/reports/tests/test")

With latest version:

getDestinationDirectory().set(file("$buildDir/reports/tests/test"))

It worked for me. Hope it'll work for you. Thanks

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文