Not sure if I should post this as an idea or as a bug.
I have an integration test task depending on a cargoStartLocal task to start a tomcat server, and finalized by a cargoStopLocal task to stop this tomcat server once the tests have been executed. The integration test task consists in setting up and populating a test database and in using Exec tasks to run tests using NodeJS:
task re2eWithServer(type: GruntTask) {
description = ‘Creates the war, start a server, creates the integration schema and populates it, then runs the re2e tests and stops the server.’
group = ‘End-to-end tests’
dependsOn war
dependsOn liquibaseDropAllInteg
dependsOn liquibaseUpdateInteg
dependsOn populateIntegDatabase
dependsOn ‘cargoStartLocal’
finalizedBy ‘cargoStopLocal’
gruntArgs = ‘re2e’
}
Unfortunately, if one of the Exec tasks executed after the cargoStartLocal has been executed fails, the build stops and the cargoStopLocal task is not executed. This leaves a Tomcat process running, and makes the next build fail since Tomcat is already running.
It would be nice if the finalizedBy task was executed even in case of a failure in the task.