1,指定要提取的文件
2,编译源码
3,复制指定的文件到指定目录
4,手动复制到服务器,整目录覆盖即可。
bat命令
client&xcopy.bat
@echo off
rem 复制自己本地,启动maven compile项目时候的命令
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"
@for /f %%i in (fileNameList.txt) do (
call :print %%i
)
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" (
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!
) else if "!suffix!"==".jsp" (
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 "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
fileNameList.txt
一行一个文件全路径。指向源码的全路径