Executing a task in a loop until a condition is met

There’s been a few posts about executing a task in a loop, but usu. with a “for-each” loop over a list.

I’d like to re-execute a task, spec. a GradleBuild task, several times until it renders “acceptable” results. That is:

tasks.register(“repeat-while-task”) {
var flag = true
while(flag) {
// execute GradleBuild task that sets new value of “flag”

Is there a way to do this?

All I can think of right now is a variant of an “Exec” task that uses the exit status of its command (a gradle command) to determine whether to execute the gradle command again.

However, I’d like to do this programmatically in the same process and use a flag as in the above code.

Any help is appreciated :slight_smile:

– Harmon