Powered by Syntax Highlighter scripts!

Running MVN build from DOS Batch file

I had to execute maven build on multiple related projects, they are not children of a parent project to be grouped under a single Maven build. So my quick dirty hack is to put a single DOS batch file to run all the "mvn clean install" commands one by one.
So my batch file looked like below;
cd \Naga\workspace\demo
echo Maven build on xyz-commons
cd xyz-commons
mvn clean install
echo Maven build on xyz-consumer
cd ..\xyz-consumer
mvn clean install

echo Maven build on xyz-services
cd ..\xyz-services
mvn clean install

echo Maven build on xyz-services-test
cd ..\xyz-services-test
mvn clean install

echo Maven build on xyz-messenger
cd ..\xyz-messenger
mvn clean install

echo Maven build on xyz-cloud-app
cd ..\xyz-cloud-app
mvn clean install

echo Go back to xyz-build folder
cd \Naga\workspace\demo\xyz-build
I was stumped when I see that the execution stopped after the first "mvn clean install" command, 
Then after quick googling I realized that mvn itself is a batch file and hence it should be called using the 'call' command! The below code works fine in getting the job done.
cd \Naga\workspace\demo
echo Maven build on xyz-commons
cd xyz-commons
call mvn clean install
echo Maven build on xyz-consumer
cd ..\xyz-consumer
call mvn clean install

echo Maven build on xyz-services
cd ..\xyz-services
call mvn clean install

echo Maven build on xyz-services-test
cd ..\xyz-services-test
call mvn clean install

echo Maven build on xyz-messenger
cd ..\xyz-messenger
call mvn clean install

echo Maven build on xyz-cloud-app
cd ..\xyz-cloud-app
call mvn clean install

echo Go back to xyz-build folder
cd \Naga\workspace\demo\xyz-build

No comments: