Skip to content

Instantly share code, notes, and snippets.

@ldaley
Created December 6, 2013 21:58

Revisions

  1. @alkemist alkemist created this gist Dec 6, 2013.
    28 changes: 28 additions & 0 deletions gistfile1.groovy
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    apply plugin: "base"

    tasks.all { task ->
    task.ext.transitiveClean = {
    tasks."clean${task.name.capitalize()}".dependsOn {
    depsOf(task).flatten().collect { "clean${it.name.capitalize()}" }
    }
    }
    }

    def depsOf(Task task, allDeps = []) {
    def thisDeps = task.taskDependencies.getDependencies(task)
    allDeps.addAll(thisDeps)
    thisDeps.each {
    depsOf(it, allDeps)
    }
    allDeps
    }

    task a
    task b
    task c {
    dependsOn a,b
    transitiveClean()
    }