Is it possible to nest tasks in gradle, such as
task foo(dependsOn: jar){
// task 1
// task 2
// task 3
.
.
.
// task n
}
where the order of execution is jar
> foo
> task 1
> task 2
> task 3
> ... > task n
? I don't want the nested tasks (i.e. task 1
, task 2
, and etc.) to be exposed to the user. I only want the foo
task to be exposed.
It looks like you can simply do the following,
task foo(dependsOn: ['clean', 'jar']){
foo << {
println "First"
}
foo << {
println "Second"
}
foo << {
println "Third"
}
.
.
.
}
where <<
is shorthand for doLast
. I think the neat thing about this approach is that only foo
is exposed..the nested tasks remain hidden from the end user. And if you execute foo
, you'll get
First
Second
Third
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With