param( [string]$Java8Home = "D:\java\jdk\jdk8" ) $ErrorActionPreference = "Stop" $projectRoot = $PSScriptRoot $sourceJar = Join-Path $projectRoot "classes\artifacts\MesOP040_jar\MesOP040.jar" $javaExe = Join-Path $Java8Home "bin\java.exe" $jreSource = Join-Path $Java8Home "jre" $jfxRuntime = Join-Path $jreSource "lib\ext\jfxrt.jar" $releaseRoot = Join-Path $projectRoot "release\MesOP040" if (-not (Test-Path -LiteralPath $sourceJar)) { throw "未找到 JAR:$sourceJar。请先在 IDEA 执行 Build Artifacts -> MesOP040:jar -> Build。" } if (-not (Test-Path -LiteralPath $javaExe) -or -not (Test-Path -LiteralPath $jfxRuntime)) { throw "Java8Home 必须指向包含 JavaFX 的 JDK 8。当前路径:$Java8Home" } if (Test-Path -LiteralPath $releaseRoot) { Remove-Item -LiteralPath $releaseRoot -Recurse -Force } New-Item -ItemType Directory -Path $releaseRoot | Out-Null Copy-Item -LiteralPath $sourceJar -Destination (Join-Path $releaseRoot "MesOP040.jar") Copy-Item -LiteralPath $jreSource -Destination (Join-Path $releaseRoot "runtime") -Recurse $launcher = @' @echo off setlocal cd /d "%~dp0" if not exist "runtime\bin\javaw.exe" ( echo Missing bundled Java runtime. pause exit /b 1 ) start "MES OP040" /b "runtime\bin\javaw.exe" -jar "MesOP040.jar" '@ Set-Content -LiteralPath (Join-Path $releaseRoot "start.bat") -Value $launcher -Encoding ASCII Write-Host "Release created: $releaseRoot"