使用bat批處理命令打包maven專案

Franson發表於2016-11-28

使用批處理命令打包java專案,給我們釋出war或jar包帶來了很大的便利,附上程式碼,以作留存。

::huap-parent
::common-parent
::market-parent
::cust-parent
::entcust-parent
::custserv-parent
::workdesk-parent
::psncust-parent
::entmarket-parent
::psnmarket-parent
::icrm

set targetWarPath=E:\Pro_2016_XXXX專案\06.開發\10.安裝包\
@echo off    #關閉顯示
@echo 查詢目錄...

@echo 當前目錄為:%cd%

@echo build huap-parent...
cd ../huap-parent
call mvn clean install

@echo build common-parent...
cd ../common-parent
call mvn clean install

@echo build market-parent...
cd ../market-parent
call mvn clean install

@echo build cust-parent...
cd ../cust-parent
call mvn clean install

@echo build entcust-parent...
cd ../entcust-parent
call mvn clean install

@echo build custserv-parent...
cd ../custserv-parent
call mvn clean install

@echo build workdesk-parent...
cd ../workdesk-parent
call mvn clean install

@echo build psncust-parent...
cd ../psncust-parent
call mvn clean install

@echo build entmarket-parent...
cd ../entmarket-parent
call mvn clean install

@echo build psnmarket-parent...
cd ../psnmarket-parent
call mvn clean install

@echo build icrm...
cd ../icrm
call mvn clean install

cd target/

set nowDate=%date:~0,4%%date:~5,2%%date:~8,2%  #獲取當前日期並設定到nowDate變數中
set newFileName=icrm[%nowDate%].war

copy icrm.war %newFileName%   #複製檔案

@echo 檔案路徑為: %cd%\%newFileName%
move %cd%\%newFileName% %targetWarPath%   #移動檔案

@echo 已成功生成[%newFileName%]安裝部署包,檔案路徑為:【%targetWarPath%%newFileName%】
pause   #暫停,阻止程式退出

  

相關文章