How to speed up the tomcat starting process in gradle?

跟風遠走 提交于 2019-12-11 04:07:04

问题


Trying to start tomcat using this gradle code snippet

task startTomcat(type:Exec) {
    workingDir tomcat_home + "\\bin"
    commandLine 'cmd', '/c', 'startup.bat'
}

After run this task tomcat is starting but gradle build process is hanged(waiting). How to solve this problem?


回答1:


You can run this task in background but it will be maybe not difficult but problematic to keep control of the running process (e.g. stopping it on demand - which might be solved by adding stopTomcat task). What You need is the following piece of code:

task startTomcat << {
   def processBuilder = new ProcessBuilder(['cmd','/c','startup.bat'])
   processBuilder.directory(new File("$tomcat_home\\bin"))
   processBuilder.start()
}

I don't guarantee that this will work as is because I don't have any windows workstation to try it out, but this is the code that should do the job after (maybe required) some altering.



来源:https://stackoverflow.com/questions/26943091/how-to-speed-up-the-tomcat-starting-process-in-gradle

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