finalizedBy and task dependencies


(Jun Wang) #1

Hi,

I am having a problem regarding executing a task at last regardless of dependent tasks failures.

For example: task runTest.configure {

println “runTest” }

task runTestFull.configure {

dependsOn ‘startServer’, ‘runTest’, ‘stopServer’ }

I want to runTestFull task executes stopServer at last even the dependent task of runTestFull fails, but I don’t want stopServer to run if I only invoke runTest task. I was trying with finalizedBy, runTestFull.finalizedBy stopServer, but stopServer task is not executed when runTest task fails. Any ideas how to resolve this? Thanks!


(Jean-Baptiste Nizet) #2

I had the same problem and solved it, thanks to the guys answering here, the following way. The thing to remember is that the finalizedBy should be set on the task that starts the server to be stopped.

task startServer {

finalizedBy ‘stopServer’

}

task stopServer {

mustRunAfter ‘runTest’

}

task runTest {

mustRunAfter ‘startServer’

}

task runTestFull {

dependsOn ‘startServer’, ‘runTest’

}


(Jun Wang) #3

Thank you!