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

Nov*_*ata 4 junit gradle deprecation-warning

task<TestReport>("testReport") {
    destinationDir = file("$buildDir/reports/allTests")
}
Run Code Online (Sandbox Code Playgroud)

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

    /**
     * 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);
    }
Run Code Online (Sandbox Code Playgroud)

小智 10

请尝试这样。

旧版本:

destinationDir = file("$buildDir/reports/tests/test")
Run Code Online (Sandbox Code Playgroud)

最新版本:

getDestinationDirectory().set(file("$buildDir/reports/tests/test"))
Run Code Online (Sandbox Code Playgroud)

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

  • destinationDirectory.set(file("$buildDir/reports/allTests")) 为我工作,在我看来更惯用 (3认同)