如何加速gradle中的tomcat启动过程? [英] How to speed up the tomcat starting process in gradle?

查看:124
本文介绍了如何加速gradle中的tomcat启动过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

运行此任务后,tomcat启动,但gradle构建过程被挂起(等待)。如何解决这个问题?

解决方案

你可以在后台运行这个任务,但它可能并不难但保持控制的问题正在运行的进程(例如根据需要停止它 - 这可以通过添加 stopTomcat 任务来解决)。您需要的是以下代码片段:

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

我不保证这将工作原样,因为我没有任何Windows工作站试用它,但这是代码应该(或许需要)之后做一些改变的工作。


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?

解决方案

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.

这篇关于如何加速gradle中的tomcat启动过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆