This message was deleted.
# community-support
s
This message was deleted.
v
The OCL is just implemented to register it as such and so make it used until all tasks are run. You can probably also do
tasks.configureEach { usesService(foo) }
and make sure the service is created somewhere to achieve the same. The build finish action is done in
close()
of
AutoCloseable
that you also implement. This is called somewhere between the service not being used anymore and the build being finished.
c
Hi @Vampire, thanks for the info. Could you please provide any example on “make it used until all tasks are run”?
v
You already have two examples of that
Register it as OCL for example
c
Thanks, I just understand a little bit. Let me give it a go
@Vampire is the BuildPhaseFinishEvent interface the event of build finished? Because the sample provided in the doc is only TaskFinishEvent. I found this event interface from the javadoc
v
It seems you didn't follow
You do your build finished code in
close()
, not in
onFinish
. Latter can be empty, it is just to ensure it is "used" until all tasks finished
c
got it. So you mean the only thing i need to do is put my code in
close()
. When implements OCL, the build service will be used in all tasks right? Please correct me if I am still wrong.
@Vampire
v
If you also implement
AutoCloseable
, yes
c
ok, got it. thanks.
Another question is: if there is no task that refers the build service. I only register the service. From the doc, I think the service will not be created. Then, the
close()
will not be executed right?
But in fact, I don’t have to use the service in any of the existing tasks.
My code is just used to handle build finished..
v
By registering it as OCL it will be created latest after the first task finishes, as it get notified about each task finish event.
c
ok, got it. thanks so much again
I am sorry but I still have another question here: I have another bulidFinish code which will do sth on build failure. However, the
close()
does not have the relevant buildResult parameter. Is it the only way to use dataflow action?
@Vampire
v
If it is about a failed task, you can remember that in
onFinish
and then evaluate in
close
.
c
Do you mean
onFinish
only handle failure tasks?
v
No
c
so what do you mean?
onFinish
still have no parameters to indicate the build status
m
Although I need to upgrade to gradle 8, it looks like this is a dead cycle.
A bit derailing, but why do you see it like that? Do you want to get rid of
buildFinished
before migrating to 8.1+? If 8.x is the end goal, I still recommend adopting
FlowAction
as soon as it is available and not bother with build services for that, as
FlowAction
is a better replacement (e.g. it can see the failed configuration phase if registered before the failure). As for Incubating - it is unlikely to change much (except for the moment when the parameterless action executes).
c
Q: Do you want to get rid of
buildFinished
before migrating to 8.1+? A: Currently the answer is yes. But just as you said, the end goal is 8.x. But upgrading to 8.x has a lot of work to do because we have many external dependent plugins that need to be upgraded. @Mikhail Lopatkin
So it’s better that i can get rid of the
buildFinished
before 8.x
v
so what do you mean?
onFinish
still have no parameters to indicate the build status
Sure it has. You need to check the type of the argument. You will get a subclass like
TaskFailedEvent
for example
c
ok, let me give it a shot