-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpackage.ps1
More file actions
80 lines (65 loc) · 2.44 KB
/
Copy pathpackage.ps1
File metadata and controls
80 lines (65 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
param(
[ValidateSet("app-image", "exe", "msi")]
[string] $Type = "app-image",
[string] $AppVersion = "1.7",
[switch] $SkipBuild
)
$ErrorActionPreference = "Stop"
$jarOutputDir = "Jar Output"
$exeOutputDir = "Exe Output"
$packageInputDir = Join-Path $jarOutputDir "jpackage-input"
$localWixBin = Join-Path $PSScriptRoot "Build Tools/WiX"
if (-not (Get-Command jpackage -ErrorAction SilentlyContinue)) {
throw "jpackage was not found. Install JDK 17 or newer and make sure its bin directory is in PATH."
}
if (($Type -eq "exe" -or $Type -eq "msi") -and -not (Get-Command candle.exe -ErrorAction SilentlyContinue)) {
if (Test-Path (Join-Path $localWixBin "candle.exe")) {
$env:PATH = "$localWixBin;$env:PATH"
}
}
if (-not $SkipBuild -or -not (Test-Path (Join-Path $jarOutputDir "Progressive-Java-Client.jar"))) {
./build.ps1
}
Remove-Item -Recurse -Force $packageInputDir -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force $packageInputDir | Out-Null
Copy-Item (Join-Path $jarOutputDir "Progressive-Java-Client.jar") $packageInputDir -Force
Copy-Item (Join-Path $jarOutputDir "Progressive-Java-Updater.jar") $packageInputDir -Force
Copy-Item (Join-Path $jarOutputDir "config.json") $packageInputDir -Force
Remove-Item -Recurse -Force $exeOutputDir -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force $exeOutputDir | Out-Null
$javaOptions = @(
"-Xmx1g",
"-Dsun.java2d.noddraw=true",
"-Drs254.logDir=logs",
"-XX:ErrorFile=logs\jvm_crash_%p.log",
"--enable-native-access=ALL-UNNAMED",
"--add-opens=java.base/java.lang=ALL-UNNAMED",
"--add-opens=java.base/java.lang.reflect=ALL-UNNAMED"
)
$args = @(
"--type", $Type,
"--name", "Progressive Java Client",
"--app-version", $AppVersion,
"--vendor", "Gradwahl",
"--description", "Progressive Java Client",
"--dest", $exeOutputDir,
"--input", $packageInputDir,
"--main-jar", "Progressive-Java-Client.jar",
"--icon", "src/main/resources/icon.ico",
"--arguments", "10 0 highmem members 32"
)
foreach ($option in $javaOptions) {
$args += @("--java-options", $option)
}
if ($Type -eq "exe" -or $Type -eq "msi") {
$args += @(
"--win-dir-chooser",
"--win-shortcut",
"--win-menu"
)
}
& jpackage @args
if ($LASTEXITCODE -ne 0) {
throw "jpackage failed with exit code $LASTEXITCODE"
}
Write-Host "Packaged Progressive Java Client into Exe Output using jpackage type '$Type'."