Slackbot
12/01/2022, 4:40 AMChris Lee
12/01/2022, 4:58 AMDoni
12/01/2022, 5:00 AMChris Lee
12/01/2022, 5:05 AMVampire
12/01/2022, 7:55 AMChris Lee
12/01/2022, 12:16 PMVampire
12/01/2022, 1:11 PMabstract class Listener : OperationCompletionListener {
override fun onFinish(event: FinishEvent?) {
println("event: $event")
}
}
interface RegistryProvider {
@get:Inject
val registry: BuildEventsListenerRegistry
}
objects.newInstance<RegistryProvider>().registry.onTaskCompletion(provider { objects.newInstance<Listener>() })
and
class Listener : OperationCompletionListener {
override fun onFinish(event: FinishEvent?) {
println("event: $event")
}
}
interface RegistryProvider {
@get:Inject
val registry: BuildEventsListenerRegistry
}
objects.newInstance<RegistryProvider>().registry.onTaskCompletion(provider { Listener() })
and both work perfectly fine with CC.Chris Lee
12/01/2022, 2:15 PMPlugins and build scripts must not register any build listeners. That is listeners registered at configuration time that get notified at execution time. For example aor aBuildListener
.TaskExecutionListener
These should be replaced by build services, registered to receive information about task execution if needed.
Chris Lee
12/01/2022, 2:15 PMVampire
12/01/2022, 2:20 PMOperationCompletionListener
is ok?
Besides that, the listener is not registered ad configuration time, that's why it is provided through a Provider
which I guess is what makes it ok.
Gradle will then probably call the provider at an appropriate time and all is well.Chris Lee
12/01/2022, 4:54 PMVampire
12/01/2022, 4:59 PMChris Lee
12/01/2022, 4:59 PMChris Lee
12/01/2022, 5:00 PMEl Zhang
12/02/2022, 11:14 AMgradle.buildFinished {
does not have a replacement api?Vampire
12/02/2022, 11:58 AMAutoCloseable
, register it as OperationCompletionListener
.
Then the close
method will be called somewhen between the last task has finished and the build is finished.El Zhang
12/02/2022, 12:00 PMEl Zhang
12/02/2022, 12:03 PMbuildEventsListenerRegistry.onTaskCompletion
only.Vampire
12/02/2022, 12:50 PMDoni
12/09/2022, 2:32 AMproject.buildScan.tag = "result"
to tag result from Listener class, but it cannot read property project inside there. Any idea how do we get result from Listener or pass some other listener to call project.buildScan.tag = "result"
? because i need to add result from listener (task executed info) on buildscan.