# Plugins: Complex Custom task type or dependency chain?

**URL:** <https://discuss.gradle.org/t/plugins-complex-custom-task-type-or-dependency-chain/25568>\
**Category:** Help/Discuss\
**Tags:** plugins\
**Created:** [January 24, 2018, 4:46pm UTC](https://discuss.gradle.org/t/plugins-complex-custom-task-type-or-dependency-chain/25568 "2018-01-24T16:46:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mpern](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@mpern](https://discuss.gradle.org/u/mpern)\
**Post date:** [January 24, 2018, 4:46pm UTC](https://discuss.gradle.org/t/plugins-complex-custom-task-type-or-dependency-chain/25568/1 "2018-01-24T16:46:20Z")

</div>

My question is similar to the one asked here:

> [@Complex task or dependency chain?](https://discuss.gradle.org/t/complex-task-or-dependency-chain/11243):
>
> I’m curious about what is the more “gradle” way to implement a complex task, as multiple small tasks that depend on each other, or as a single task doing a lot of work. This stems primarily from the fact that it’s often easier to configure individual tasks, but it’s harder to get an overview, and in my particular case, the tasks aren’t that meaningful on their own. Example pseudo code: task modifyZip \<\< { exec { delete old files } ant.unzip { the files } exec { operate on extracted files } …

The difference is:

I’m trying to write a Gradle plugin (in Java) and one of the tasks it should provide requires multiple processing steps (build, generate some custom folder structure in a temp folder, copy and generate files, zip everything together and a few other things).

Should I hide this complexity in a huge custom task class (and possible re-implement a lot of stuff) or preconfigure smaller tasks + dependencies to leverage task types gradle provides out-of-the-box?

What’s the more “gradle” solution for plugins?

---

<div class="post-metadata">

**Author:** ![bmuschko](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/bmuschko/32/5458_2.png) [@bmuschko](https://discuss.gradle.org/u/bmuschko)\
**Post date:** [January 24, 2018, 5:01pm UTC](https://discuss.gradle.org/t/plugins-complex-custom-task-type-or-dependency-chain/25568/2 "2018-01-24T17:01:20Z")

</div>

I’d create one task for each step and chain them together with task dependencies. The benefit is that is easier to use core task types and you know exactly what failed if something fails.

---

<div class="post-metadata">

**Author:** ![st\_oehme](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/st_oehme/32/5249_2.png) [@st\_oehme](https://discuss.gradle.org/u/st_oehme)\
**Post date:** [January 24, 2018, 5:13pm UTC](https://discuss.gradle.org/t/plugins-complex-custom-task-type-or-dependency-chain/25568/3 "2018-01-24T17:13:03Z")

</div>

Also you get finer grained caching and up to date checking that way. If step one produces the same output, then step 2 and 3 will be up to date. If everything is in one big step, it’ll all rerun.
