diff --git a/lib/com/oracle/javafx/jfxrt/8.0/jfxrt-8.0.jar b/lib/com/oracle/javafx/jfxrt/8.0/jfxrt-8.0.jar deleted file mode 100644 index 8b620f9..0000000 Binary files a/lib/com/oracle/javafx/jfxrt/8.0/jfxrt-8.0.jar and /dev/null differ diff --git a/pom.xml b/pom.xml index 0d5b840..86ec9ef 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,8 @@ 17 17 17 - 17 + + UTF-8 UTF-8 @@ -26,13 +27,10 @@ 17.0.14 2.0.1 + + C:\Program Files\Java\jdk-17 - - - local-lib-repo - file://${project.basedir}/lib - sonatype-snapshots @@ -196,6 +194,20 @@ + + + org.apache.maven.plugins + maven-compiler-plugin + 3.11.0 + + 17 + true + true + ${jdk17.home}\bin\javac + 17 + + + org.springframework.boot spring-boot-maven-plugin @@ -228,7 +240,8 @@ org.springframework.boot.loader.JarLauncher - 1.8.0 + jre + 17 -Dfile.encoding=UTF-8 diff --git a/scripts/build_release.bat b/scripts/build_release.bat index 13882a6..77a9cca 100644 --- a/scripts/build_release.bat +++ b/scripts/build_release.bat @@ -1,31 +1,37 @@ @echo off chcp 65001 >nul -setlocal enabledelayedexpansion +setlocal :: ============================================ -:: WorkUtils 生产打包脚本 -:: 输出:target\dist\workutils-v{version}.zip(含 exe + jar + bat + config) +:: WorkUtils 生产打包脚本(免安装版) +:: 输出:target\dist\workutils-v{version}.zip +:: (含 exe + 内嵌JRE + jar + 启动脚本) :: ============================================ ::: 切换到项目根目录 cd /d "%~dp0.." -set PROJECT_DIR=%CD% -set TARGET=%PROJECT_DIR%\target -set DIST=%TARGET%\dist -set VERSION= +set "PROJECT_DIR=%CD%" +set "TARGET=%PROJECT_DIR%\target" +set "DIST=%TARGET%\dist" +set "VERSION=" echo. echo ========== WorkUtils 生产构建 ========== +echo 项目目录: %PROJECT_DIR% echo. -:: 1. 杀掉可能占用 target 的进程 -echo [1/4] Clean stale processes... -taskkill /f /im java.exe 2>nul +::: ============================================================ +::: 步骤 1:清理残留进程 +::: ============================================================ +echo [1/5] Clean stale processes... +taskkill /f /im java.exe 2>nul taskkill /f /im workutils.exe 2>nul -:: 2. Maven 打包 +::: ============================================================ +::: 步骤 2:Maven 打包 +::: ============================================================ echo. -echo [2/4] Maven build... +echo [2/5] Maven build... call "%PROJECT_DIR%\mvnw.cmd" clean package -DskipTests -q if %errorlevel% neq 0 ( echo [ERROR] Maven build failed! @@ -33,42 +39,142 @@ if %errorlevel% neq 0 ( exit /b 1 ) -:: 3. 提取版本号 -for /f "tokens=2 delims=>" %%i in ('findstr /c:"" "%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. 准备发布目录 +::: ============================================================ +::: 步骤 3:提取版本号(PowerShell 解析 pom.xml) +::: ============================================================ echo. -echo [3/4] Assemble distribution... +echo [3/5] Read version from pom.xml... +for /f "usebackq delims=" %%a in (`powershell -NoProfile -NonInteractive -Command "([xml](Get-Content -Encoding UTF8 '%PROJECT_DIR%\pom.xml')).project.version"`) do set "VERSION=%%a" +if "%VERSION%"=="" set "VERSION=0.0.1-SNAPSHOT" +echo 版本: %VERSION% + +::: ============================================================ +::: 步骤 4:生成精简 JRE(jlink 内嵌 Java 17 + JavaFX) +::: ============================================================ +echo. +echo [4/5] Generate bundled JRE... + +::: 4.1 查找 JDK 17(环境变量 JDK17_HOME > 默认路径) +if not defined JDK17_HOME ( + for %%d in ( + "C:\Program Files\Java\jdk-17" + "C:\Program Files\Eclipse Adoptium\jdk-17.0.0.35-hotspot" + "C:\Program Files\Java\jdk-17.0.14" + "%JAVA_HOME%" + ) do ( + if exist "%%~d\bin\jlink.exe" ( + set "JDK17_HOME=%%~d" + goto :jdk17_found + ) + ) + echo [ERROR] Cannot find JDK 17 with jlink.exe + echo Please set JDK17_HOME environment variable + pause & exit /b 1 +) +:jdk17_found + +::: 4.2 查找 JavaFX SDK(环境变量 JFX_SDK_HOME > 默认路径) +if not defined JFX_SDK_HOME ( + for %%d in ( + "C:\Program Files\Java\javafx-sdk-17.0.15" + "C:\Program Files\Java\javafx-sdk-17.0.14" + "C:\Program Files\Java\javafx-sdk-17" + ) do ( + if exist "%%~d\lib\javafx.base.jar" ( + set "JFX_SDK_HOME=%%~d" + goto :jfx_found + ) + ) + echo [ERROR] Cannot find JavaFX SDK + echo Please set JFX_SDK_HOME environment variable + pause & exit /b 1 +) +:jfx_found + +echo JDK : %JDK17_HOME% +echo JavaFX: %JFX_SDK_HOME% + +::: 4.3 清理旧 JRE +if exist "%TARGET%\jre" rd /s /q "%TARGET%\jre" + +::: 4.4 执行 jlink +echo Running jlink, please wait... +"%JDK17_HOME%\bin\jlink.exe" ^ + --module-path "%JFX_SDK_HOME%\lib;%JDK17_HOME%\jmods" ^ + --add-modules java.base,java.desktop,java.logging,java.management,java.naming,java.sql,java.xml,java.xml.crypto,java.instrument,java.security.jgss,java.security.sasl,jdk.unsupported,jdk.management,java.scripting,jdk.crypto.ec,java.net.http,javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.web,javafx.swing ^ + --output "%TARGET%\jre" ^ + --strip-debug --no-header-files --no-man-pages --compress=2 + +if %errorlevel% neq 0 ( + echo [ERROR] jlink failed! + pause + exit /b 1 +) +echo [OK] JRE generated : %TARGET%\jre + +::: ============================================================ +::: 步骤 5:组装发布目录 & 打包 ZIP +::: ============================================================ +echo. +echo [5/5] 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 +::: 复制 EXE +if exist "%TARGET%\workutils.exe" ( + copy /y "%TARGET%\workutils.exe" "%DIST%\workutils\" >nul + echo [OK] workutils.exe +) else ( + echo [WARN] workutils.exe not found! +) -:: 生成发布用的启动脚本(JAR 在同一个目录下) ->"%DIST%\workutils\start.bat" ( +::: 复制 JAR +for %%j in ("%TARGET%\workutils-*.jar") do ( + copy /y "%%j" "%DIST%\workutils\" >nul + echo [OK] %%~nxj +) + +::: 复制内嵌 JRE +if exist "%TARGET%\jre\bin\java.exe" ( + xcopy /e /i /q "%TARGET%\jre" "%DIST%\workutils\jre\" >nul + echo [OK] jre/ ^(bundled Java 17 + JavaFX^) +) else ( + echo [WARN] jre not found in target! +) + +::: ============================================================ +::: 生成 start.bat(备选启动方式) +::: ============================================================ +( echo @echo off echo chcp 65001 ^>nul echo title WorkUtils echo java -jar "%%~dp0workutils-%VERSION%.jar" %%* echo pause -) +) > "%DIST%\workutils\start.bat" +echo [OK] start.bat -:: 打包成 zip(保留 workutils 目录结构) -set ZIPNAME=workutils-v%VERSION% -powershell -Command "Compress-Archive -Path '%DIST%\workutils' -DestinationPath '%DIST%\%ZIPNAME%.zip' -Force" +::: ============================================================ +::: 打包 ZIP +::: ============================================================ +set "ZIPNAME=workutils-v%VERSION%" +echo 正在压缩 %ZIPNAME%.zip ... +powershell -Command ^ + "Compress-Archive -Path '%DIST%\workutils' -DestinationPath '%DIST%\%ZIPNAME%.zip' -Force" +echo [OK] %ZIPNAME%.zip -:: 5. 完成 +::: ============================================================ +::: 完成 +::: ============================================================ echo. -echo [4/4] Build complete! +echo ============================================ +echo Build Complete ^! v%VERSION% echo ============================================ echo Output: -echo exe : target\workutils.exe -echo jar : target\workutils-%VERSION%.jar -echo zip : target\dist\%ZIPNAME%.zip +echo %DIST%\workutils\ +echo %DIST%\%ZIPNAME%.zip echo ============================================ echo. pause diff --git a/scripts/fix_urls.java b/scripts/fix_urls.java deleted file mode 100644 index b55b067..0000000 --- a/scripts/fix_urls.java +++ /dev/null @@ -1,27 +0,0 @@ -import java.nio.file.*; -import java.util.*; - -public class fix_urls { - public static void main(String[] args) throws Exception { - // Fix both template and data files - String[] files = {"data/project_paths.txt", "src/main/resources/templates/project_paths.txt"}; - for (String file : files) { - Path p = Paths.get(file); - List lines = Files.readAllLines(p, java.nio.charset.StandardCharsets.UTF_8); - int fixed = 0; - for (int i = 0; i < lines.size(); i++) { - String l = lines.get(i); - if (l.contains("=") && l.endsWith("cf/")) { - int eq = l.lastIndexOf('='); - String path = l.substring(0, eq).trim(); - String url = l.substring(eq + 1).trim(); - String proj = path.substring(path.lastIndexOf('/') + 1); - lines.set(i, path + "=" + url + proj + ".git"); - fixed++; - } - } - Files.write(p, lines, java.nio.charset.StandardCharsets.UTF_8); - System.out.println(file + ": fixed " + fixed + " lines, total " + lines.size()); - } - } -}