Skip to content

Instantly share code, notes, and snippets.

@yuki-teraoka
Created March 2, 2015 02:36
Show Gist options
  • Save yuki-teraoka/61c16bbed292c648fd72 to your computer and use it in GitHub Desktop.
Save yuki-teraoka/61c16bbed292c648fd72 to your computer and use it in GitHub Desktop.
Gradle dependsOnSerial
@Category(Task)
class TaskExtension {
void dependsOnSerial(List<Task> tasks) {
if (!tasks) return
tasks.each { this.dependsOn it }
def firstTask = tasks.pop();
tasks.reverse().inject(firstTask) { after, before ->
after.shouldRunAfter before
before
}
}
void dependsOnSerial(Object... tasks) {
dependsOnSerial((List<Task>)tasks.flatten().collect{ it as Task ? it : project.tasks[it] })
}
}
Task.mixin(TaskExtension)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment