Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to declare dependencies of a Gradle custom task?

If I've created a custom task:

class MyTask extends DefaultTask {
   ...
}

I can at another time create an instance and declare dependencies:

task(["type": MyTask, "dependsOn": importantThing], "MyTaskName")

However, it seems a bit weird to separate the task definition from the declaration of dependencies. That is, it seems like everything defining the task should be in one place, or else it would be easy to instantiate the task without the right dependencies. Is there some better way to do this?

like image 417
Cannoliopsida Avatar asked Oct 12 '25 02:10

Cannoliopsida


1 Answers

Tasks should be generic and self-contained. They should only operate on their own input properties, and should not assume existence of other tasks. Declaring tasks and their dependencies is the responsibility of build scripts and/or plugins.

like image 155
Peter Niederwieser Avatar answered Oct 15 '25 13:10

Peter Niederwieser