Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle 6.0 deprecation warning for JacocoReport configuration

The following Gradle task, which configures JacocoReportBase:

task jacocoRootReport(type: JacocoReport) {
    ...
    sourceDirectories = files(subprojects.sourceSets.main.allSource.srcDirs)
    additionalSourceDirs = files(subprojects.sourceSets.main.allSource.srcDirs)
    classDirectories = files(subprojects.sourceSets.main.output)
    executionData = files(subprojects.jacocoTestReport.executionData)
    ...
}

produces these warnings, when building with ./gradlew assembleDebug --warning-mode all:

The JacocoReportBase.setSourceDirectories(FileCollection) method has been deprecated.
This is scheduled to be removed in Gradle 6.0. Use getSourceDirectories().from(...)
at tasks_1p10s36ydq4k8rroeiucekewi$_run_closure6.doCall(.../tasks.gradle:152)

The JacocoReportBase.setAdditionalSourceDirs(FileCollection) method has been deprecated.
This is scheduled to be removed in Gradle 6.0. Use getAdditionalSourceDirs().from(...)
at tasks_1p10s36ydq4k8rroeiucekewi$_run_closure6.doCall(.../tasks.gradle:151)

The JacocoReportBase.setClassDirectories(FileCollection) method has been deprecated.
This is scheduled to be removed in Gradle 6.0. Use getClassDirectories().from(...)
at tasks_1p10s36ydq4k8rroeiucekewi$_run_closure6.doCall(.../tasks.gradle:153)

The JacocoReportBase.setExecutionData(FileCollection) method has been deprecated.
This is scheduled to be removed in Gradle 6.0. Use getExecutionData().from(...)
at tasks_1p10s36ydq4k8rroeiucekewi$_run_closure6.doCall(.../tasks.gradle:154)

How to use the Gradle 6.0 compatible syntax (as the deprecation warning suggests) to apply the desired values with these methods (passing the argument in brackets somehow does not work):

  • getAdditionalSourceDirs().from(...)
  • getSourceDirectories().from(...)
  • getClassDirectories().from(...)
  • getExecutionData().from(...) ?
like image 684
Martin Zeitler Avatar asked May 17 '19 06:05

Martin Zeitler


People also ask

What is jacocoTestReport?

JaCoCo Report configurationThe JacocoReport task can be used to generate code coverage reports in different formats. It implements the standard Gradle type Reporting and exposes a report container of type JacocoReportsContainer. Example 4. Configuring test task. build.gradle.

What is gradle project in Java?

Gradle is a build automation tool known for its flexibility to build software. A build automation tool is used to automate the creation of applications. The building process includes compiling, linking, and packaging the code. The process becomes more consistent with the help of build automation tools.


1 Answers

Setter .from can be used alike this:

task jacocoRootReport(type: JacocoReport) {
    ...
    sourceDirectories.from = subprojects.sourceSets.main.allSource.srcDirs
    additionalSourceDirs.from = subprojects.sourceSets.main.allSource.srcDirs
    classDirectories.from = subprojects.sourceSets.main.output
    executionData.from = subprojects.jacocoTestReport.executionData
    ...
}
like image 184
Martin Zeitler Avatar answered Oct 05 '22 14:10

Martin Zeitler