【问题标题】:testReport destinationDir is deprecated in gradle 7.4.2 so how to set it?testReport destinationDir 在 gradle 7.4.2 中已弃用,那么如何设置呢?
【发布时间】:2022-07-21 02:57:51
【问题描述】:
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);
    }

【问题讨论】:

  • 这没有意义,因为尝试使用这个新属性会导致编译器错误

标签: gradle junit deprecation-warning


【解决方案1】:

请这样尝试。

旧版本:

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

最新版本:

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

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

【讨论】:

    猜你喜欢
    • 2013-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-22
    • 2017-12-14
    • 2018-12-16
    • 1970-01-01
    相关资源
    最近更新 更多