是啊!雅得添加
jettyRunWar {
daemon = true
}
到您的build.gradle。然後,如果你想在年底關閉服務器啊,你必須投這也:
stopPort = 1234
stopKey = 'stopKey'
// gradle is luser. Full story (and code copied from): https://issues.gradle.org/browse/GRADLE-2263
import org.gradle.api.plugins.jetty.internal.Monitor
[jettyRun, jettyRunWar]*.doLast {
/**
* THIS IS A WORKAROUND! THE CURRENT VERSION OF THIS TASK DOESN'T START A WATCHER IN DAEMON MODE
*
* If starting the monitor fails, it may be because the jetty task was updated to fix this issue
* When that happens, we shouldn't need the custom task any more
*
* Copied From: AbstractJettyRunTask
*/
if (getStopPort() != null && getStopPort() > 0 && getStopKey() != null) {
Monitor monitor = new Monitor(getStopPort(), getStopKey(), server.getProxiedObject());
monitor.start();
}
}
確保你有關於「gradle這個是luser」的評論。
你有沒有考慮[使用junit](http://stackoverflow.com/questions/20707017/how-to-run-junit-tests-with-gradle),[或者像這樣](http:// java .dzone.com/articles/gradle-goodness-running-single) – Paxic
對,我試圖使用JUnit,但是如果我嘗試運行我的服務器,以便我可以運行我的測試,那麼Gradle不會從任務返回運行服務器,以便它永遠不會運行測試。 –