New*_*ser 1 java batch-file maven
我有一个批处理文件,让我的生活更轻松。
我想构建一个 Maven 项目,然后将分发版从目标文件夹复制到另一个文件夹,然后解压缩它们,然后是一些复制替换说明。当代码没有问题时,这工作得很好。
如果构建有任何问题并且构建失败,那么我想停止批处理执行。
我无法弄清楚。
::Kill all the java processs
taskkill /f /im "java.exe"
::Take the sprint number form the user
set /p sprintNumber=Enter the sprint number:%=%
:: Navigate to the code path
cd D:\Sprint-%sprintNumber%
call D:
:: Build the code
::@echo ###############BUILDING####################
::call mvn clean install
::cd ..
::Remove the distribution
IF EXIST "D:\Distribution\Sprint-%sprintNumber%\" (
rmdir "D:\Distribution\Sprint-%sprintNumber%\" /s /q
)
::Few more instructions
Run Code Online (Sandbox Code Playgroud)
如果 maven 安装失败,我想停止执行。请提供任何建议以完成此任务。
在构建命令之后的行上添加类似
if errorlevel 1 echo An error occurred & pause & goto :EOF
Run Code Online (Sandbox Code Playgroud)