What is the exact difference between dependsOn and finalizedBy?

I saw this question from 2013 (FinalizedBy vs DependsOn, difference in "gradle tasks" output) but it is pretty old so asking again for clarity

What is the difference betweeen check and test here?:

check.dependsOn jacocoTestReport

plugins.withType(JacocoPlugin) {
   tasks["test"].finalizedBy 'jacocoTestReport'
}

?

If you run gw check, jacocoTestReport runs first and check runs only if jacocoTestReport was successful.

If you run gw test, jacocoTestReport is run after test finished, no matter whether test was successful or not (unless there additionally is jacocoTestReport.dependsOn(test), then only if test was successful).

1 Like