For running end-to-end tests, I have tasks that start up my application with a test configuration, run tests against it, and then stop the application. They are configured like:
test.dependsOn startApp
startApp.finalizedBy stopApp
stopApp.mustRunAfter test
Using ‘finalizedBy’ ensures that the app is stopped even if tests fail or something else goes wrong. However, sometimes when I’m developing a test or running one interactively, I’d like to run ‘startApp’ and have the application stay running, i.e. not run the finalizer task.
My thought was to do this with a predicate, along the lines of:
stopApp.onlyIf { /* startApp was not explicitly listed on the command line */ }
Is there any way tell, from the task execution graph or something else, which tasks were explicitly asked for on the command line and which are only running as dependencies? If not, can you suggest another approach to this problem? Thank you!