Files
homeutils/scripts/build_release.bat
T
张家训 711193a503 ①逆向工程插件支持多数据源
②打包体积缩小
2026-06-16 18:19:04 +08:00

75 lines
2.0 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@echo off
chcp 65001 >nul
setlocal enabledelayedexpansion
:: ============================================
:: WorkUtils 生产打包脚本
:: 输出:target\dist\workutils-v{version}.zip(含 exe + jar + bat + config)
:: ============================================
::: 切换到项目根目录
cd /d "%~dp0.."
set PROJECT_DIR=%CD%
set TARGET=%PROJECT_DIR%\target
set DIST=%TARGET%\dist
set VERSION=
echo.
echo ========== WorkUtils 生产构建 ==========
echo.
:: 1. 杀掉可能占用 target 的进程
echo [1/4] Clean stale processes...
taskkill /f /im java.exe 2>nul
taskkill /f /im workutils.exe 2>nul
:: 2. Maven 打包
echo.
echo [2/4] Maven build...
call "%PROJECT_DIR%\mvnw.cmd" clean package -DskipTests -q
if %errorlevel% neq 0 (
echo [ERROR] Maven build failed!
pause
exit /b 1
)
:: 3. 提取版本号
for /f "tokens=2 delims=>" %%i in ('findstr /c:"<version>" "%PROJECT_DIR%\pom.xml" ^| findstr /v "xml" ^| findstr /n "1" ^| findstr "1:"') do (
for /f "tokens=1 delims=<" %%v in ("%%i") do set VERSION=%%v
)
if "%VERSION%"=="" set VERSION=0.0.1-SNAPSHOT
:: 4. 准备发布目录
echo.
echo [3/4] Assemble distribution...
if exist "%DIST%" rd /s /q "%DIST%"
mkdir "%DIST%\workutils" 2>nul
copy /y "%TARGET%\workutils.exe" "%DIST%\workutils\" >nul
copy /y "%TARGET%\workutils-%VERSION%.jar" "%DIST%\workutils\" >nul
:: 生成发布用的启动脚本(JAR 在同一个目录下)
>"%DIST%\workutils\start.bat" (
echo @echo off
echo chcp 65001 ^>nul
echo title WorkUtils
echo java -jar "%%~dp0workutils-%VERSION%.jar" %%*
echo pause
)
:: 打包成 zip(保留 workutils 目录结构)
set ZIPNAME=workutils-v%VERSION%
powershell -Command "Compress-Archive -Path '%DIST%\workutils' -DestinationPath '%DIST%\%ZIPNAME%.zip' -Force"
:: 5. 完成
echo.
echo [4/4] Build complete!
echo ============================================
echo Output:
echo exe : target\workutils.exe
echo jar : target\workutils-%VERSION%.jar
echo zip : target\dist\%ZIPNAME%.zip
echo ============================================
echo.
pause