Question
Can I somehow make sure that the task will be completed before / after another task, when both of them should be completed? I do not want to add a dependency between them that always exists.
Background
I have two tasks, one of which starts the server, and the other - tests. The task that starts this server is to start it in a new process, so I can start gradle startServer runServerTests . Since it takes some time to start the server, it should be possible to start the server with one gradle process and then run the tests several times using another gradle process.
Now I'm trying to create one task that does everything that our CI environment does, which includes starting the server and running server tests. Obviously, I want to make sure that the server is running before running the tests, but so far I'm out of luck.
Attempts
My first attempt is below, but this does not work, since the order of certain dependencies is not guaranteed :
task doItAll(dependsOn: [startServer, runServerTests]) { ... }
My second attempt, calling tasks in actions does not work and is not supported :
task doItAll() << { tasks.startServer.execute() tasks.runServerTests.execute() }
The solutions are on the roadmap ( GRADLE-294 , Initializer / Finalizer ), but that does not help me now.
source share