Slackbot
12/08/2023, 8:50 PMNuh Koca
12/08/2023, 8:50 PMdef jacocoFullReport = tasks.register("jacocoFullReport", JacocoReport) {
group = 'Reporting'
description = 'Generates an aggregated report from all subprojects'
def projects = subprojects.findAll { project -> !isModuleExcluded(project) }
dependsOn(projects.jacocoTestReport)
final source = files(projects.jacocoTestReport.sourceDirectories)
additionalSourceDirs.setFrom(source)
sourceDirectories.setFrom(source)
classDirectories.setFrom(files(projects.jacocoTestReport.classDirectories))
executionData.setFrom(files(projects.jacocoTestReport.executionData))
reports {
html.required = true
html.outputLocation = layout.buildDirectory.dir("reports/jacoco/html")
xml.required = true
xml.outputLocation = layout.buildDirectory.file("reports/jacoco/jacocoFullReport.xml")
}
}
Nuh Koca
12/08/2023, 8:52 PMval jacocoFullReport = tasks.register("jacocoFullReport", JacocoReport::class) {
group = "Reporting"
description = "Generates an aggregated report from all subprojects"
val projects = subprojects
.filter { it.tasks.findByName("jacocoTestDebugUnitTestReport") != null }
.map { it.tasks.getByName("jacocoTestDebugUnitTestReport", JacocoReport::class) }
dependsOn(projects)
val source = files(projects.flatMap { it.sourceDirectories })
additionalSourceDirs.setFrom(source)
sourceDirectories.setFrom(source)
classDirectories.setFrom(files(projects.flatMap { it.classDirectories }))
executionData.setFrom(files(projects.flatMap { it.executionData.files }))
reports {
html.required.set(true)
html.outputLocation.set(layout.buildDirectory.dir("reports/jacoco/html"))
xml.required.set(true)
xml.outputLocation.set(layout.buildDirectory.file("reports/jacoco/jacocoFullReport.xml"))
}
}
Nuh Koca
12/08/2023, 8:54 PMorg.gradle.api.tasks.TaskExecutionException: Execution failed for task ':jacocoFullReport'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:149)
... org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:47)
Caused by: java.io.IOException: Error while analyzing DataStoreCachedValue$getValue$$inlined$map$1$2.class with JaCoCo 0.8.9.202303310957/c0ad781.
at org.jacoco.core.analysis.Analyzer.analyzerError(Analyzer.java:163)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:135)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:158)
at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:195)
at org.jacoco.ant.ReportTask.createBundle(ReportTask.java:573)
at org.jacoco.ant.ReportTask.createReport(ReportTask.java:545)
at org.jacoco.ant.ReportTask.execute(ReportTask.java:496)
... 154 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 13 out of bounds for length 13
Vampire
12/08/2023, 9:57 PMjava.lang.ArrayIndexOutOfBoundsException: Index 13 out of bounds for length 13
during JaCoCo analysis afair usually come when your Java version is newer than what your JaCoCo version supports. It is very unlikely that this is caused by Kotlin DSL vs. Groovy DSL.
But besides that, you really should not do such unsafe reaching into project model and results of other projects.
To learn how to properly and safely share things between projects, have a look at https://docs.gradle.org/current/userguide/cross_project_publications.html.
And especially for your case, just use https://docs.gradle.org/current/userguide/jacoco_report_aggregation_plugin.html which uses exactly these techniques to provide aggregated reports.Nuh Koca
12/08/2023, 10:10 PMVampire
12/08/2023, 10:18 PMNuh Koca
12/09/2023, 6:46 PM0.8.11
breaks but 0.8.9
works