Skip to content

Commit 707fdaa

Browse files
committed
Fix windows build - add Maven for jpackage only
1 parent 4ba9ecb commit 707fdaa

2 files changed

Lines changed: 14 additions & 20 deletions

File tree

.github/workflows/build-desktop.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,25 +174,22 @@ jobs:
174174

175175
- name: Create Windows installer
176176
run: |
177-
# Junction for short JAVA_HOME (used only when calling jpackage to avoid CreateProcess path limit)
177+
# Short JAVA_HOME/PATH for jpackage only (avoids "filename or extension is too long")
178178
if (Test-Path C:\j) { cmd /c rmdir C:\j }
179179
cmd /c mklink /J C:\j $env:JAVA_HOME
180+
$env:JAVA_HOME = "C:\j"
181+
$env:PATH = "C:\j\bin;C:\Windows\System32;C:\Windows"
180182
subst X: $env:GITHUB_WORKSPACE
181183
New-Item -ItemType Directory -Force -Path "C:\t" | Out-Null
182184
cd X:\desktop-client
183-
$MAVEN_VERSION = mvn help:evaluate -Dexpression=project.version -q -DforceStdout
184-
$APP_VERSION = $MAVEN_VERSION -replace "-SNAPSHOT", "" -replace "-.*", ""
185-
if ($APP_VERSION -notmatch "\.") {
186-
$APP_VERSION = "$APP_VERSION.0"
187-
}
188-
$JAR_NAME = (Get-ChildItem target\desktop-client-*.jar | Select-Object -First 1).Name
185+
$jarFile = Get-ChildItem target\desktop-client-*.jar | Select-Object -First 1
186+
$JAR_NAME = $jarFile.Name
187+
$APP_VERSION = ($jarFile.BaseName -replace 'desktop-client-', '') -replace '-SNAPSHOT', '' -replace '-.*', ''
188+
if ($APP_VERSION -notmatch "\.") { $APP_VERSION = "$APP_VERSION.0" }
189189
$ICON_ARG = ""
190190
if (Test-Path "src\main\resources\icons\app-icon.ico") {
191191
$ICON_ARG = "--icon src\main\resources\icons\app-icon.ico"
192192
}
193-
# Short PATH only for jpackage to avoid "filename or extension is too long"
194-
$env:JAVA_HOME = "C:\j"
195-
$env:PATH = "C:\j\bin;C:\Windows\System32;C:\Windows"
196193
jpackage --input target `
197194
--name "JSTutor" `
198195
--main-jar $JAR_NAME `

.github/workflows/release-desktop.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,25 +76,22 @@ jobs:
7676
- name: Build installers and portable app image (Windows)
7777
if: matrix.os == 'windows-latest'
7878
run: |
79-
# Junction for short JAVA_HOME (used only when calling jpackage to avoid CreateProcess path limit)
79+
# Short JAVA_HOME/PATH for jpackage only (avoids "filename or extension is too long")
8080
if (Test-Path C:\j) { cmd /c rmdir C:\j }
8181
cmd /c mklink /J C:\j $env:JAVA_HOME
82+
$env:JAVA_HOME = "C:\j"
83+
$env:PATH = "C:\j\bin;C:\Windows\System32;C:\Windows"
8284
subst X: $env:GITHUB_WORKSPACE
8385
New-Item -ItemType Directory -Force -Path "C:\t" | Out-Null
8486
cd X:\desktop-client
85-
$MAVEN_VERSION = mvn help:evaluate -Dexpression=project.version -q -DforceStdout
86-
$APP_VERSION = $MAVEN_VERSION -replace "-SNAPSHOT", "" -replace "-.*", ""
87-
if ($APP_VERSION -notmatch "\.") {
88-
$APP_VERSION = "$APP_VERSION.0"
89-
}
90-
$JAR_NAME = (Get-ChildItem target\desktop-client-*.jar | Select-Object -First 1).Name
87+
$jarFile = Get-ChildItem target\desktop-client-*.jar | Select-Object -First 1
88+
$JAR_NAME = $jarFile.Name
89+
$APP_VERSION = ($jarFile.BaseName -replace 'desktop-client-', '') -replace '-SNAPSHOT', '' -replace '-.*', ''
90+
if ($APP_VERSION -notmatch "\.") { $APP_VERSION = "$APP_VERSION.0" }
9191
$ICON_ARG = ""
9292
if (Test-Path "src\main\resources\icons\app-icon.ico") {
9393
$ICON_ARG = "--icon src\main\resources\icons\app-icon.ico"
9494
}
95-
# Short PATH only for jpackage to avoid "filename or extension is too long"
96-
$env:JAVA_HOME = "C:\j"
97-
$env:PATH = "C:\j\bin;C:\Windows\System32;C:\Windows"
9895
jpackage --input target `
9996
--name "JSTutor" `
10097
--main-jar $JAR_NAME `

0 commit comments

Comments
 (0)