How to add on to default task


(binarylegit) #1

I am writing a test plugin that I want to be run at the same time as all of the other test tasks, is there a proper way to have my plugin’s task get run during the ‘test’ task?


(Szczepan Faber) #2

Hello!

There are a couple of ways to solve this use case.

For example, you can make the existing tasks (e.g. ‘check’ or ‘test’) depend on your tasks. For example:

//given the java plugin is applied and 'test'/'check' tasks have been added:
project.tasks.test.dependsOn(myTask)
project.tasks.check.dependsOn(myOtherTask)

Alternatively, you can create a new task that runs all test tasks + your desired tasks. You should declare appropriate task dependencies to make sure all desired tasks are ran when you run the ‘aggregate’ task.

Hope that helps!