This message was deleted.
# configuration-cache
s
This message was deleted.
v
What is that task doing?
a
Running on all the xmls reports generated by the
:jacocoTestReport
tasks in each subproject, parse them and returns us the total coverage for the whole project
v
And how do you get hold of the XMLs?
a
I'm walking the project in look for them
Copy code
val totalCoverage = File(project.rootDir.absolutePath)
                    .walk()
                    .filter { it.name.endsWith(".uatDebug.xml") }
                    .toList()
                    .mapNotNull { file -> JacocoReportParser.parse(file) }
                    .run {
                        val totalCovered = sumOf { it.covered }
                        val totalMissed = sumOf { it.missed }
                        return@run (totalCovered / (totalCovered + totalMissed).toDouble()) * 100
                    }
v
Now there you have the problem. That's highly unsafe and discouraged bad practice. If you would properly use cross-project publication, you would not need any explicit
dependsOn
. Actually, any explicit
dependsOn
that does not have a lifecycle task on the left-hand side is a small and most probably a sign that inputs and output are not properly wired as it should be. Here you can read about how to properly share outputs between projects: https://docs.gradle.org/current/userguide/cross_project_publications.html You can also have a look at the JaCoCo report aggregation plugin or test report aggregation plugin which use that approach to create aggregated reports across projects.
You probably can also just use the JaCoCo report aggregation plugin to generate an aggregated report and then just read the number you are interested in from there.
a
I used it in the past, but that means we don't have a task per subproject anymore, and it makes it harder (and longer) to work with JaCoCo then. Thanks, I will look into how to wire those outputs as my input correctly!
v
Why don't you have a task per project anymore? And how does that make it harder to work with JaCoCo?
a
If I remember correctly, I didn't have a dedicated per-module JaCoCo XML and HTML report when used with https://github.com/gmazzo/gradle-android-test-aggregation-plugin And as we have 200+ modules, it is faster to run the coverage report on the module we're working on vs the whole project (aggregated) all the time
v
I have no idea about that plugin. I talked about the standard plugins. And at least those just provide additional aggregation tasks, but the individual tasks stay there unchanged
a
Ah ok, that might also be an option, but I thimk there's a missing piece for Android so that's why https://github.com/gmazzo/gradle-android-test-aggregation-plugin exists. I'll check again the whole suject. @Vampire Thanks a lot for your help 😊
v
Could be that there is a missing integration piece, yeah. I'm not into Android development. But I would expect it to be relatively simply to make it work with an Android build. It is basically just about creating and filling the proper outgoing variants that are requested by the aggregator. A week ago I also used the JaCoCo report aggregation plugin to make a report across test types which is not supported out-of-the-box. 🙂
👍 1