I am writing a Gradle plugin for a custom type of project. The goal of the plugin is to run some tests which are each described in the build file using a DSL.
Constraints of my project:
Before any test is run, I need to start a server which will gather the test reports (task “‘reportServer.start’”).
After all tests are run, I need to stop the server (task “‘reportServer.stop’”).
I wish to allow the user to launch all the tests described in the DSL with the command “‘gradle runTests’”.
I wish to allow the user to launch any list of tests chosen individually with a command like “‘gradle test1.run test2.run test3.run’”.
Question: How to plug the tasks ‘reportServer.start’ and ‘reportServer.stop’ so that they are executed at the right time?
For the task ‘reportServer.start’, it’s easy: each test task can depend on it. For the task ‘reportServer.stop’, I didn’t find any satisfying solution and that’s the problem.