Thanks Peter for the input. Here is the solution that worked for me using ProcessBuilder
:
/* Configuration for tomcat */
task catalinaConfig {
ext.binDir = ENV['CATALINA_HOME'] + "\bin"
}
task startTomcat << {
println "Tomcat path: " + catalinaConfig.binDir
ProcessBuilder pb = new ProcessBuilder(["cmd", "/c", "catalina.bat", "start"]);
pb.directory(new File(catalinaConfig.binDir));
println "Starting tomcat now ... "
Process proc = pb.start();
proc.waitFor();
println "Tomcat is coming up now ... " + proc.exitValue()
}
task stopTomcat << {
println "Tomcat path: " + catalinaConfig.binDir
ProcessBuilder pb1 = new ProcessBuilder(["cmd", "/c", "catalina.bat", "stop"]);
pb1.directory(new File(catalinaConfig.binDir));
println "Stopping tomcat now ... "
Process proc1 = pb1.start();
proc1.waitFor();
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…