jdk Version:11
gradle Version:7.5
jacoco Version:0.8.8
jacoco.gradle Part of the code is as follows:
task jacocoTotalReport(type: JacocoReport, dependsOn: project.getTasksByName("testDebugUnitTest", true)) {
doFirst {
subprojects.each { project ->
def unitTestResultFile = "${project.buildDir}/jacoco/testDebugUnitTest.exec"
if (file(unitTestResultFile).exists() && executionData != null) {
executionData.setFrom(unitTestResultFile)
}
}
}
}
Error content:
> The value for this file collection is final and cannot be changed.
Removing the doFirst block does not report an error but does not generate a report.
task jacocoTotalReport(type: JacocoReport, dependsOn: project.getTasksByName("testDebugUnitTest", true)) {
subprojects.each { project ->
def unitTestResultFile = "${project.buildDir}/jacoco/testDebugUnitTest.exec"
if (file(unitTestResultFile).exists() && executionData != null) {
executionData.setFrom(unitTestResultFile)
}
}
}