@echo off
SET DEVELOPMENT_HOME=C:\Projects
cd %DEVELOPMENT_HOME%\Project1\
call mvn clean install
cd %DEVELOPMENT_HOME%\Project2\
call mvn clean install
Joey 的回答很棒,但是也许一个更完整的代码示例可以帮助像我这样的人解决从 Windows 批处理文件中构建多个 maven 项目的类似问题:
REM maven itself uses a batch file so each mvn must be preceded by "call"
REM the -f flag specifies where the pom.xml is found for the project
REM mvn install will save the target output to %userprofile%\.m2\repository ...
call mvn install -f c:\Users\John\workspace\PropertiesReader\pom.xml
call mvn install -f c:\Users\John\workspace\PropertiesWriter\pom.xml
Use these commands in batch file to run ur script. Keep your batch file where
you pom.xml file is housed
set ProjectPath=C:\TetonWorkSpace\PeriodicApplicationCheck
cd %ProjectPath%
mvn clean test -Dxmlfile=Smoke.xml
pause
To Create a Task in Task scheduler:
1. Follow steps as prescribed to create task
2. In the action tab, just place the path of ur batch file as shown below
C:\TetonWorkSpace\PeriodicApplicationCheck\testng.bat
3. You can ignore the rest two options like Add Argument and Start in. Use it
only when there are certain conditions to be used without which the script
becomes dysfunctional.