Code_X
Code_X

Reputation: 33

How to speed up the tomcat starting process in gradle?

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?

Upvotes: 2

Views: 950

Answers (1)

Opal
Opal

Reputation: 84784

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.

Upvotes: 1

Related Questions