Answers:
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
我还有更多项目要运行,我创建了这样的蝙蝠:
@echo off
SET DEVELOPMENT_HOME=C:\Projects
cd %DEVELOPMENT_HOME%\Project1\
call mvn clean install
cd %DEVELOPMENT_HOME%\Project2\
call mvn clean install
观察到的行为来自MS-DOS 1.0的时间,出于兼容性原因而保留它,因为解决方案必须以以下方式使用Windows 调用函数:
call mvn clean
call mvn package
“调用”从另一个执行一个批处理程序,并将其解释为子例程。
我们可以使用以下命令构建一个Maven并将其传递给任何unix文件夹以用于开发目的
SET projectName=commonutil
cd %gitpath%\%projectName%
call mvn clean install -DskipTests=true %password%
IF %ERRORLEVEL% EQU 0 (Echo No error found) ELSE goto exitdoor
SET jarpath="%gitpath%\%projectName%\target\%projectName%-0.0.1-SNAPSHOT.jar"
copy /Y %jarpath% "%libpath%"
scpg3 %jarpath% %ssh_profile_name%@%hostname%:%dev_lib_folder_name%
用
呼叫 mvn clean package
sample
------
echo %test%
cd %test%\ManaulActionAddNotes-test
call mvn clean
cd %test%\restAuthentication-test
call mvn clean
gradle