finalizeBy not running on a build failure

(Jeff Storey) #1

I have a build task that looks like:

task someTask {
   dependsOn a, b, c
someTask.finalizedBy d

When I run this, task b runs codenarc and the build fails, and then task d is not run. I thought that in this case d should run.

I’m not sure if it is relevant, but in this case, b is not the codenarc task itself, rather b has tasks that it depends on, one of which is codenarc.

(Peter Niederwieser) #2

‘d’ is a finalizer for ‘someTask’. It won’t run if some other task (e.g. some dependency of ‘someTask’ failed.

(Jeff Storey) #3

Thanks for the quick reply. I think I understand, but I want to clarify one point.

In this case I ran

gradle someTask

, so is this the expected behavior still? If so, is that because task someTask isn’t considered started until it gets past the dependencies and actually runs someTask?

(Peter Niederwieser) #4

Yes, that’s correct. ‘someTask.finalizedBy(d)’ is kind of similar to Java’s ‘try { someTask } finally { d }’. ‘someTask’'s dependencies come before that, and aren’t part of ‘someTask’.

(Jeff Storey) #5

Got it, thanks.