This message was deleted.
# configuration-cache
s
This message was deleted.
v
I did something similar with spotbugs tasks. It was a while back with Gradle 5.6.2, but back then I also resorted to
tasks.withType<...>().all { ... }
which effectively is the same as
tasks.withType<...> { ... }
. I don't think anything changed since then.
c
Yeah that’s effectively what we’re doing right now. Hmm
I almost want a
whenTaskRegistered
callback where the task is still TaskProvider<TheOtherTask>, in a context where I can call
registerTask
. So the other task doesn’t have to get registered, and neither does mine if it’s not called.
v
Welcome to the club. 😄 I think there is even an issue for it somewhere, but I'm not finding it right now.
What you maybe could do is to not handle the
JacocoReport
tasks, but derive them from where they are registered from. You will not get custom
JacocoReport
tasks covered, but for the standard tasks it should work.
c
By derive them do you mean check out the jacoco plugin and gradle and effectively follow the same logic?
v
Exactly
e
could rules work?
Copy code
tasks.addRule("after jacoco") {
    val baseName = removeSuffix("JacocoReportFinisher")
    if (equals(baseName)) return@addRule
    tasks.register(this) {
        dependsOn(baseName)
        doLast { ... }
    }
}
tasks.withType<JacocoReport>().configureEach {
    finalizedBy("${name}JacocoReportFinisher")
}
completely untested but something along those lines
v
Hm, interesting idea. I tend to forget task rules as I try to avoid them.
a
what sort of task did you want to register @Clayton Walker? Is it something that can be done with a
doLast {}
block, and dynamically registering inputs/outputs?
c
Perhaps? This is a classic example of “we use plugin x, plugin x doesn’t support new gradle feature y, go fix it”
In this case I’m trying to retrofit modern gradle-isms onto a plugin that still supports gradle 5
These retrofits always beg the question tho, should I try to keep what’s there as intact as possible, or maybe rethink the way the plugin is written.
a
I think dynamically registering new tasks based on other tasks might be too difficult, but it should be possible to collect the JaCoCo report files created by the JaCoCo tasks, and then register a single task that consumes them
something like this?
v
Explicit paths and `dependsOn`s 😨
c
Perhaps I should look into the
Copy code
jacoco-report-aggregation
plugin, see how that works.