Skip to content

Commit bf7c742

Browse files
committed
Update jpackage task
1 parent 3d9923a commit bf7c742

File tree

6 files changed

+27
-74
lines changed

6 files changed

+27
-74
lines changed

.github/workflows/gradle_package.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
66
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
77

8-
name: Package Distribution with Gradle
8+
name: Package Distribution Artifacts
99

1010
on:
1111
workflow_dispatch:
1212
inputs:
1313
version:
1414
description: "Version"
1515
required: false
16-
default: SNAPSHOT
16+
default: 1.0.0-SNAPSHOT
1717

1818
permissions:
1919
contents: read
@@ -23,9 +23,9 @@ jobs:
2323
strategy:
2424
matrix:
2525
configuration: [
26-
{ runner: "macos-13", task: "jpackageMac", path: "build/dist/*" },
27-
{ runner: "macos-14", task: "jpackageMac", path: "build/dist/*" },
28-
{ runner: "windows-2022", task: "jpackageWin", path: "build/dist/*" }
26+
{ runner: "macos-13", path: "build/dist/*" },
27+
{ runner: "macos-14", path: "build/dist/*" },
28+
{ runner: "windows-2022", path: "build/dist/*" }
2929
]
3030
runs-on: ${{ matrix.configuration.runner }}
3131
steps:
@@ -39,7 +39,7 @@ jobs:
3939
- name: Setup Gradle
4040
uses: gradle/actions/setup-gradle@v4
4141
- name: Package app with Gradle
42-
run: ./gradlew ${{ matrix.configuration.task }}
42+
run: ./gradlew jpackage
4343
- name: Upload Artifact
4444
uses: actions/upload-artifact@v4
4545
with:

.github/workflows/release.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: Release on Tag
2+
13
on:
24
push:
35
tags:
@@ -22,9 +24,9 @@ jobs:
2224
strategy:
2325
matrix:
2426
configuration: [
25-
{ runner: "macos-13", task: "jpackageMac", path: "build/dist" },
26-
{ runner: "macos-14", task: "jpackageMac", path: "build/dist" },
27-
{ runner: "windows-2022", task: "jpackageWin", path: "build/dist" }
27+
{ runner: "macos-13", path: "build/dist" },
28+
{ runner: "macos-14", path: "build/dist" },
29+
{ runner: "windows-2022", path: "build/dist" }
2830
]
2931
runs-on: ${{ matrix.configuration.runner }}
3032
steps:
@@ -38,7 +40,7 @@ jobs:
3840
- name: Setup Gradle
3941
uses: gradle/actions/setup-gradle@v4
4042
- name: Package app with Gradle
41-
run: ./gradlew ${{ matrix.configuration.task }} -Pversion="${{ github.ref_name }}"
43+
run: ./gradlew jpackage -Pversion="${{ github.ref_name }}"
4244
- name: Upload Asset
4345
shell: bash
4446
run: |

build.gradle

Lines changed: 15 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import io.github.fvarrui.javapackager.gradle.PackageTask
2-
import io.github.fvarrui.javapackager.model.SetupMode
3-
import io.github.fvarrui.javapackager.model.WindowsExeCreationTool
41
import org.gradle.internal.jvm.Jvm
52
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
63
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
@@ -10,9 +7,6 @@ buildscript {
107
repositories {
118
mavenCentral()
129
}
13-
dependencies {
14-
classpath "io.github.fvarrui:javapackager:1.7.6"
15-
}
1610
}
1711

1812
plugins {
@@ -23,8 +17,6 @@ plugins {
2317
id "org.jetbrains.dokka" version "2.0.0"
2418
}
2519

26-
apply plugin: 'io.github.fvarrui.javapackager.plugin'
27-
2820
group 'ru.nucodelabs'
2921

3022
java {
@@ -198,52 +190,10 @@ test {
198190
finalizedBy cleanRunDir
199191
}
200192

201-
javapackager {
202-
mainClass = application.mainClass
203-
bundleJre = true
204-
organizationName = "NucodeLabs"
205-
name = "GEM"
206-
applicationName = "GEM"
207-
version = project.version
208-
vmArgs = ["-Djava.library.path=."] + moduleExportsJvmArgs
209-
administratorRequired = false
210-
additionalResources = [
211-
file("lib/${System.mapLibraryName("MathVES_JNI")}"),
212-
file("lib/${System.mapLibraryName("MathVES")}")
213-
]
214-
}
193+
/* jpackage */
215194

216-
tasks.register('packageWindowsExe', PackageTask) {
217-
dependsOn build
218-
generateInstaller = false
219-
winConfig {
220-
generateSetup = false
221-
generateMsi = false
222-
exeCreationTool = WindowsExeCreationTool.launch4j
223-
icoFile = file("src/main/resources/img/gem.ico")
224-
setupMode = SetupMode.askTheUser
225-
removeOldLibs = true
226-
disableDirPage = false
227-
disableFinishedPage = false
228-
disableWelcomePage = false
229-
createDesktopIconTask = false
230-
}
231-
finalizedBy distClr
232-
}
233-
234-
tasks.register('packageLinuxApplication', PackageTask) {
235-
dependsOn build
236-
generateInstaller = true
237-
linuxConfig {
238-
generateDeb = true
239-
generateRpm = true
240-
wrapJar = true
241-
pngFile = file("src/main/resources/img/gem.png")
242-
}
243-
finalizedBy distClr
244-
}
195+
def jpackageInputDir = layout.buildDirectory.dir("jars").get().asFile.absolutePath
245196

246-
def jpackageInputDir = layout.buildDirectory.dir("jars")
247197
tasks.register("copyNativeDependencies", Copy) {
248198
from file("$projectDir/lib/${System.mapLibraryName("MathVES_JNI")}"),
249199
file("$projectDir/lib/${System.mapLibraryName("MathVES")}")
@@ -264,23 +214,24 @@ final Map<String, String> jpackageCommonOptions = [
264214
"APP_NAME" : "GEM",
265215
"APP_VERSION" : project.version.toString().replaceAll(/[^0-9.]/, ""),
266216
"DEST" : layout.buildDirectory.dir("dist").get().asFile.absolutePath,
267-
"INPUT" : layout.buildDirectory.dir("jars").get().asFile.absolutePath,
217+
"INPUT" : jpackageInputDir,
268218
"MAIN_CLASS" : application.mainClass.get(),
269219
"MAIN_JAR" : tasks.jar.archiveFileName.get(),
270-
"APP_CONTENT" : file("src/main/resources").absolutePath,
271-
"RESOURCE_DIR": file("package").absolutePath
220+
"APP_CONTENT" : file("$projectDir/src/main/resources").absolutePath,
221+
"RESOURCE_DIR": file("$projectDir/package_resources").absolutePath
272222
]
273223

274-
tasks.register("jpackageMac", Exec) {
224+
tasks.register("jpackage", Exec) {
275225
dependsOn "build", "copyJar", "copyDependencies", "copyNativeDependencies"
276226
workingDir = projectDir
277-
commandLine "bash", "jpackage_mac.sh"
278227
environment(jpackageCommonOptions)
279-
}
280228

281-
tasks.register("jpackageWin", Exec) {
282-
dependsOn "build", "copyJar", "copyDependencies", "copyNativeDependencies"
283-
workingDir = projectDir
284-
commandLine "cmd", "/c", "jpackage_win.bat"
285-
environment(jpackageCommonOptions)
286-
}
229+
def os = DefaultNativePlatform.currentOperatingSystem
230+
if (os.isMacOsX()) {
231+
commandLine "bash", "jpackage_mac.sh"
232+
} else if (os.isWindows()) {
233+
commandLine "cmd", "/c", "jpackage_win.bat"
234+
} else {
235+
throw new StopActionException("Platform is not supported: ${os}")
236+
}
237+
}

0 commit comments

Comments
 (0)