Maven: multiple builds from cmd file

This is just a followup on/refinement of my previous post. This cmd/bat Script focuses on clean-build-installing multiple projects from a single script. This script halts at the first build failure. If you happen to run from window explorer by doble clicking the script, In case of error the command window stays open (Press any key to continue). If ever build was successful, the window closes automatically. In the following example, I am skipping the test execution for third project you can add/remove -DskipTests=true to any mvn calls.

REM Uncomment following if you want to clean local repo on each run
REM rmdir /S /Q "%HOMEPATH%\.m2\repository\com\mygroup\id"

call mvn -f ProjectA\pom.xml clean install
if not "%ERRORLEVEL%" == "0" goto error

call mvn -f ProjectB\pom.xml clean install
if not "%ERRORLEVEL%" == "0" goto error

call mvn -DskipTests=true -f ProjectC\pom.xml clean install
if not "%ERRORLEVEL%" == "0" goto error


@echo Build Failed

Hope you find this helpful.

This  question at SO helped.

No comments: