Gradle JacocoReport 配置的 6.0 弃用警告
Gradle 6.0 deprecation warning for JacocoReport configuration
以下 Gradle 任务,配置 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)
...
}
在使用 ./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)
如何使用 Gradle 6.0 兼容语法(如弃用警告所建议的那样)通过这些方法应用所需的值(以某种方式在括号中传递参数不起作用):
getAdditionalSourceDirs().from(...)
getSourceDirectories().from(...)
getClassDirectories().from(...)
getExecutionData().from(...)
?
Setter .from
可以像这样使用:
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
...
}
以下 Gradle 任务,配置 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)
...
}
在使用 ./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)
如何使用 Gradle 6.0 兼容语法(如弃用警告所建议的那样)通过这些方法应用所需的值(以某种方式在括号中传递参数不起作用):
getAdditionalSourceDirs().from(...)
getSourceDirectories().from(...)
getClassDirectories().from(...)
getExecutionData().from(...)
?
Setter .from
可以像这样使用:
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
...
}