build-exe.ps1 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Build MES TuHan (projection welding) Windows exe
  2. # Requires: Maven + JDK 8+
  3. # Run: .\pack\build-exe.ps1
  4. $ErrorActionPreference = "Stop"
  5. $Root = Split-Path -Parent $PSScriptRoot
  6. if (-not (Test-Path (Join-Path $Root "pom.xml"))) {
  7. Write-Error "pom.xml not found. Run from HuHan project."
  8. }
  9. Set-Location $Root
  10. Write-Host "Project: $Root"
  11. Write-Host "Running: mvn -Pexe clean package"
  12. if (-not (Get-Command mvn -ErrorAction SilentlyContinue)) {
  13. Write-Error "mvn not found in PATH"
  14. }
  15. & mvn -Pexe clean package
  16. if ($LASTEXITCODE -ne 0) {
  17. Write-Error "Maven failed, exit=$LASTEXITCODE"
  18. }
  19. $dist = Join-Path $Root "pack\dist"
  20. New-Item -ItemType Directory -Path $dist -Force | Out-Null
  21. $exe = Join-Path $dist "tuhan-client.exe"
  22. if (-not (Test-Path $exe)) {
  23. Write-Error "exe not found: $exe"
  24. }
  25. $cfgDir = Join-Path $dist "config"
  26. New-Item -ItemType Directory -Path $cfgDir -Force | Out-Null
  27. $ymlSrc = Join-Path $Root "src\main\resources\config\application.yml"
  28. $ymlDst = Join-Path $cfgDir "application.yml"
  29. if (Test-Path $ymlSrc) {
  30. Copy-Item $ymlSrc $ymlDst -Force
  31. }
  32. $readmePath = Join-Path $dist "README.txt"
  33. @(
  34. "MES TuHan Client"
  35. ""
  36. "1. Install Java 8+ (JRE/JDK). Check: java -version"
  37. "2. Double-click tuhan-client.exe"
  38. "3. Edit config\application.yml for server-ip / station / COM port"
  39. " Exe already loads optional:./config/ next to the exe."
  40. ""
  41. "Output: $exe"
  42. ) | Set-Content -Path $readmePath -Encoding ASCII
  43. Write-Host ""
  44. Write-Host "OK: $exe"
  45. Write-Host "Config sample: $ymlDst"
  46. Write-Host "Readme: $readmePath"