tomcat 增量部署,覆盖 提取文件 -支持Builder,$1,$2,$3等命名的class文件

该脚本主要用于Java项目的自动化处理,包括编译源码,复制指定文件到特定目录,然后将编译后的文件覆盖到服务器。它支持特定类的覆盖,并记录覆盖的文件数量。脚本还涉及到了Maven的配置和文件路径的转换,以及.jsp和.js文件的部署。
摘要由CSDN通过智能技术生成

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

:print

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值