Gradle - How to add some delay pause hang in Gradle

独自空忆成欢 提交于 2019-12-06 00:09:28

问题


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?


回答1:


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.




回答2:


If you want to run integration tests in Tomcat, then simply use the Gradle Tomcat Plugin like this:

ext {
    tomcatStopPort = 8081
    tomcatStopKey = 'stopKey'
}

task integrationTomcatRun(type: org.gradle.api.plugins.tomcat.TomcatRun) {
    stopPort = tomcatStopPort
    stopKey = tomcatStopKey
    daemon = true
}

task integrationTomcatStop(type: org.gradle.api.plugins.tomcat.TomcatStop) {
    stopPort = tomcatStopPort
    stopKey = tomcatStopKey
}

task integrationTest(type: Test) {
    include '**/*IntegrationTest.*'
    dependsOn integrationTomcatRun
    finalizedBy integrationTomcatStop
}

test {
    exclude '**/*IntegrationTest.*'
}


来源:https://stackoverflow.com/questions/21293888/gradle-how-to-add-some-delay-pause-hang-in-gradle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!