Gradle - How to add some delay pause hang in Gradle

AKS picture AKS · Jan 22, 2014 · Viewed 15.2k times · Source

Im looking for a way to insert a pause of few seconds between the calls of two gradle tasks.

I can use

firstTask.doLast {

.....

}

something like which can do Linux/Unix

sleep 45

Any ideas?

Answer

Peter Niederwieser picture Peter Niederwieser · Jan 22, 2014

First, I'd try to find a better solution than waiting for so long every time. Anyway, to delay the first task for 45 seconds, you can do:

firstTask.doLast {
    sleep(45 * 1000)
}

A good way to familiarize yourself with Groovy's core APIs is to study the Groovy JDK (also known as GDK). It's also a handy reference.