BuildDeploy.bat
cscript /nologo c:\Utils\stopjboss.vbs set JBOSS_DEPLOYMENT=c:\jboss\standalone\deployments set DEVELOPMENT_HOME=c:\projectName set BRANCH=BranchName\ReleaseNo del /q %JBOSS_DEPLOYMENT%\*.* cd %DEVELOPMENT_HOME%\%BRANCH% call mvn clean call mvn install -o IF EXISTS %DEVELOPMENT_HOME%\%BRANCH%\SpringMVC.war ( goto :startServer ) else ( echo Build Failed ) exit /b :startServer copy %DEVELOPMENT_HOME%\%BRANCH%\SpringMVC.war %JBOSS_DEPLOYMENT% cscript /nologo c:\Utils\startjboss.vbs goto :eof
startjboss.vbs
Set WshShell = WScript.CreateObject("WScript.Shell") activateServer("Server") WshShell.SendKeys "%{d}" Function activateServer(windowName) WshShell.SendKeys "^{3}" WScript.Sleep 500 WshShell.SendKeys windowName WScript.Sleep 500 WshShell.SendKeys "{ENTER}" End Function
stopjboss.vbs
Set WshShell = WScript.CreateObject("WScript.Shell") activateServer("Server") WshShell.SendKeys "%{s}" WScript.Sleep 5000
How it Works
- We are using a VBScript to Start and Stop server by Sending Key Strokes to Eclipse(Shortcut Keys)
- The mvn clean and mvn install is done in 2 different steps to make sure that clean of the war files happen before the new file is created since executing clean and install in single shot happened to give inconsistent results
- Once the build is done we are checking whether the war file is created or we are assuming the build failed and we are not starting the server
- The builddeploy.bat should be configured in External Tools Configuration
- Workdirectory is the one which has pom.xml of the project
- Assign a shortcut key to Run Last Run Build Configuration