1,指定要提取的文件
2,编译源码
3,复制指定的文件到指定目录
4,手动复制到服务器,整目录覆盖即可。
支持覆盖-包含Builder,$1,$2,$3等 命名的class类
添加覆盖文件计数
@echo off
call E:\dev\java1.8\bin\java.exe -Dmaven.multiModuleProjectDirectory=E:\IdeaGiftProject\gift -Dmaven.home=E:\dev\IntelliJ_IDEA_2018_1_2\plugins\maven\lib\maven3 -Dclassworlds.conf=E:\dev\IntelliJ_IDEA_2018_1_2\plugins\maven\lib\maven3\bin\m2.conf -javaagent:E:\dev\IntelliJ_IDEA_2018_1_2\lib\idea_rt.jar=57391:E:\dev\IntelliJ_IDEA_2018_1_2\bin -Dfile.encoding=UTF-8 -classpath E:\dev\IntelliJ_IDEA_2018_1_2\plugins\maven\lib\maven3\boot\plexus-classworlds-2.5.2.jar org.codehaus.classworlds.Launcher -Didea.version=2018.1.2 -s C:\Users\ab\.m2\settings_gift.xml compile -f E:\IdeaGiftProject\gift\pom.xml
setlocal enabledelayedexpansion
set "Ymd=%date:~,4%%date:~5,2%%date:~8,2%"
set Tss=%TIME:~6,2%
set Tmm=%TIME:~3,2%
set Thh=%TIME:~0,2%
set Thh=%Thh: =0%
set parentPath=gift-%Ymd%-%Thh%.%Tmm%.%Tss%
rem 源码存放的位置
set "varOld=E:\IdeaGiftProject\gift\src\main\java"
rem 编译后代码存放的位置
set "varTarget=E:\IdeaGiftProject\gift\target\classes"
rem 把需要部署的文件-class 指定目标目录
set "varServer=E:\bat\gift_deploy\%parentPath%\gift\WEB-INF\classes"
rem 界面源码位置
set "varHtmlOld=E:\IdeaGiftProject\gift\src\main\webapp"
rem 把需要部署的文件-html,jsp,js 指定目标目录
set "varHtmlServer=E:\bat\gift_deploy\%parentPath%\gift"
set /a sum=0
@for /f %%i in (fileNameList.txt) do (
call :print %%i
)
echo "success copy[%sum%]files"
endlocal
pause
goto :eof
rem 获取到文件路径
set file_path=%~dp1
rem echo %file_path%
rem 获取到文件名称
set file_name=%~n1
rem echo %file_name%
rem 获取到文件后缀
set suffix=%~x1
rem echo %suffix%
rem 截取倒数第四个开始 截取四个长度
set specStr=%file_name:~-4,4%
if "!suffix!"==".java" (
set /a sum=sum+1
rem set "var=%var:/=//%"
rem java路径,转换到target/class
set "file_source_path=!file_path:%varOld%=%varTarget%!"
rem set "file_path=%file_path:D:\IdeaProjects\jeecg-zb-2020\src\main\java=D:\IdeaProjects\jeecg-zb-2020\target\classes%"
rem target/class路径,转换到要部署的目标文件夹
set "to_path=!file_source_path:%varTarget%=%varServer%!"
rem set "to_path=%file_path:D:\IdeaProjects\jeecg-zb-2020\target\classes=C:\Users\Administrator\Desktop\deploy\server%"
rem echo %dest_path%
if not exist !to_path! ( md !to_path! )
set ss_path="!file_source_path!%file_name%.class"
echo "source_path:"!ss_path!
echo "server_path:"!to_path!
xcopy /r /y !ss_path! !to_path!
rem copy $.class,Builder.class
set "file_source_path_E1=!file_path:%varOld%=%varTarget%!"
set "file_source_path_E1_name=%file_name%$%file_name%Builder.class"
set "file_source_path_$1_name=%file_name%$1.class"
set "file_source_path_$2_name=%file_name%$2.class"
set "file_source_path_$3_name=%file_name%$3.class"
set "file_source_path_$4_name=%file_name%$4.class"
rem 全路径拼接
set "file_source_path_B1_AllPath=!file_source_path_E1!!file_source_path_E1_name!"
set "file_source_path_$1_AllPath=!file_source_path_E1!!file_source_path_$1_name!"
set "file_source_path_$2_AllPath=!file_source_path_E1!!file_source_path_$2_name!"
set "file_source_path_$3_AllPath=!file_source_path_E1!!file_source_path_$3_name!"
set "file_source_path_$4_AllPath=!file_source_path_E1!!file_source_path_$4_name!"
if exist !file_source_path_B1_AllPath! (
xcopy /r /y !file_source_path_B1_AllPath! !to_path!
set /a sum=sum+1
)
if exist !file_source_path_$1_AllPath! (
xcopy /r /y !file_source_path_$1_AllPath! !to_path!
set /a sum=sum+1
)
if exist !file_source_path_$2_AllPath! (
xcopy /r /y !file_source_path_$2_AllPath! !to_path!
set /a sum=sum+1
)
if exist !file_source_path_$3_AllPath! (
xcopy /r /y !file_source_path_$3_AllPath! !to_path!
set /a sum=sum+1
)
if exist !file_source_path_$4_AllPath! (
xcopy /r /y !file_source_path_$4_AllPath! !to_path!
set /a sum=sum+1
)
) else if "!suffix!"==".jsp" (
set /a sum=sum+1
set "to_html_path=!file_path:%varHtmlOld%=%varHtmlServer%!"
set "source_html_path=%file_path%%file_name%%suffix%"
echo "source_html_path:"!source_html_path!
echo "to_html_path:"!to_html_path!
if not exist !to_html_path! ( md !to_html_path! )
xcopy /r /y !source_html_path! !to_html_path!
) else if "!suffix!"==".js" (
set /a sum=sum+1
set "to_js_path=!file_path:%varHtmlOld%=%varHtmlServer%!"
set "source_js_path=%file_path%%file_name%%suffix%"
echo "source_js_path:"!source_js_path!
echo "to_js_path:"!to_js_path!
if not exist !to_js_path! ( md !to_js_path! )
xcopy /r /y !source_js_path! !to_js_path!
)
rem 可以自行添加 js,jpg,其他静态资源,同jsp