Search code examples
gradletaskconcept

What is the difference between concepts Custom Task and Enhanced Task in Gradle?


I often meet in Gradle documentation these concepts. What is the difference between them?

From what I know custom task is class that encapsulates some logic, but what is enhanced task and what is the difference between them?


Solution

  • A simple task in Gradle is an instance of DefaultTask and does not do anything out of the box. To make it do something you have to add code to the task definition in your build script.

    An enhanced task is an instance of a different class (for example a Copy task is an instance of Copy) and has some behaviour out of the box. You just need to configure that behaviour in your build script (eg tell it where to copy from and to)

    A custom task is an enhanced task that is an instance of a class you wrote yourself.