Skip to content

Instantly share code, notes, and snippets.

@topera
Last active June 28, 2018 00:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save topera/cd8ee8fe633c7962a1802bb5f70cac14 to your computer and use it in GitHub Desktop.
Save topera/cd8ee8fe633c7962a1802bb5f70cac14 to your computer and use it in GitHub Desktop.
How to run gradle tasks in sequence in a easy way
Task.metaClass.runFirst = { Task... others ->
delegate.dependsOn(others)
delegate.mustRunAfter(others[0])
for (def i=0; i < others.size() - 1; i++) {
def before = others[i]
def after = others[i+1]
after.mustRunAfter(before)
}
}
task x {
doFirst{
println "X"
}
}
task a {
doFirst{
println "A"
}
}
task b {
doFirst{
println "B"
}
}
task c {
doFirst{
println "C"
}
}
x.runFirst a,b,c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment