Skip to content

Instantly share code, notes, and snippets.

@noel-yap
Created September 16, 2013 18:27
Show Gist options
  • Select an option

  • Save noel-yap/6584523 to your computer and use it in GitHub Desktop.

Select an option

Save noel-yap/6584523 to your computer and use it in GitHub Desktop.
Recursively set Gradle task dependency.
class TaskUtil {
static def recursivelyApplyToTaskDependencies(Task parent, Closure closure) {
closure(parent)
parent.dependsOn.findAll { dependency ->
dependency instanceof Task
}.each { task ->
recursivelyApplyToTaskDependencies(task, closure)
}
}
static def recursivelyAddTaskDependency(Task parent, Task dependency) {
recursivelyApplyToTaskDependencies(parent) { p ->
if (!p.name.equals(dependency.name)) {
p.dependsOn(dependency)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment