How to inject tasks between test and build task?

I’ve created custom tasks for running the integration and acceptance tests. Is it possible to make them run after test and before the build task? I need to run them in this order: test->integrationTest->acceptacnceTest->build. Please note that I only want this to happen when I execute build task. Individual testing tasks should not depend on each other.

Use ‘mustRunAfter’ to enforce task ordering without specifying a dependency.

build {

dependsOn [acceptanceTest, integrationTest]


acceptanceTest {

mustRunAfter integrationTest


integrationTest {

mustRunAfter test


This is what I was looking for. Thank you.