Use jpackage for windows/linux distribution
ci/woodpecker/push/woodpecker Pipeline failed Details
ci/woodpecker/push/docs Pipeline was successful Details

This commit is contained in:
Johannes Frohnmeyer 2023-05-05 15:27:25 +02:00
parent 6151f0e71e
commit 50e9db1fcc
Signed by: Johannes
GPG Key ID: E76429612C2929F4
2 changed files with 77 additions and 8 deletions

View File

@ -3,36 +3,38 @@
pipeline:
export_metadata:
image: gradle:jdk19-jammy
image: git.frohnmeyer-wds.de/johannes/ci-wine
pull: true
commands:
- mkdir public
- gradle --build-cache :exportMetadata -Ppublic -Ptimestamp=${CI_PIPELINE_STARTED}
- mv version.json public/
build_platform_jars:
image: gradle:jdk19-jammy
image: git.frohnmeyer-wds.de/johannes/ci-wine
commands:
- gradle --build-cache :launcher-dist:build -Pflavor=fat -Ppublic -Ptimestamp=${CI_PIPELINE_STARTED}
- gradle --build-cache :launcher-dist:build -Pflavor=windows -Ppublic -Ptimestamp=${CI_PIPELINE_STARTED}
- gradle --build-cache :launcher-dist:build -Pflavor=linux -Ppublic -Ptimestamp=${CI_PIPELINE_STARTED}
- gradle --build-cache :launcher-dist:build :launcher-dist:jpackage -Pflavor=windows -Ppublic -Pcrosscompile -Ptimestamp=${CI_PIPELINE_STARTED}
- gradle --build-cache :launcher-dist:build :launcher-dist:jpackage -Pflavor=linux -Ppublic -Ptimestamp=${CI_PIPELINE_STARTED}
- gradle --build-cache :launcher-dist:build -Pflavor=macos -Ppublic -Ptimestamp=${CI_PIPELINE_STARTED}
- mv launcher-dist/build/jpackage/*.deb public/inceptum.deb
- mv launcher-dist/build/jpackage/*.msi public/inceptum.msi
- for f in launcher-dist/build/libs/Inceptum-*-*-*.jar; do mv "$f" "public/Inceptum-$${f##*-}"; done
- mv public/Inceptum-fat.jar public/Inceptum.jar
build_wrapper:
image: gradle:jdk19-jammy
image: git.frohnmeyer-wds.de/johannes/ci-wine
commands:
- gradle --build-cache :wrapper:build -Pflavor=windows -Ppublic -Ptimestamp=${CI_PIPELINE_STARTED}
- cp wrapper/build/libs/*.exe public/wrapper.exe
- cp wrapper/build/libs/*-all.jar public/wrapper.jar
publish_debug:
image: gradle:jdk19-jammy
image: git.frohnmeyer-wds.de/johannes/ci-wine
commands:
- gradle --build-cache build publish -Pflavor=maven -Ppublic -Ptimestamp=${CI_PIPELINE_STARTED}
secrets: [ maven_token, maven_name ]
when:
- branch: master
publish_release:
image: gradle:jdk19-jammy
image: git.frohnmeyer-wds.de/johannes/ci-wine
commands:
- gradle --build-cache build publish -Pflavor=maven -Ppublic -Prelease
secrets: [ maven_token, maven_name ]
@ -40,7 +42,7 @@ pipeline:
- event: tag
branch: master
portable:
image: gradle:jdk19-jammy
image: git.frohnmeyer-wds.de/johannes/ci-wine
commands:
- apt update
- apt install -y p7zip-full curl jq

View File

@ -1,9 +1,11 @@
plugins {
id("inceptum.application-standalone")
id("org.beryx.runtime") version "1.13.0"
}
application {
mainClass.set("io.gitlab.jfronny.inceptum.Inceptum")
applicationName = "Inceptum"
}
dependencies {
@ -30,4 +32,69 @@ publishing {
from(components["java"])
}
}
}
val flavor: String by rootProject.extra
val os = org.gradle.internal.os.OperatingSystem.current()!!
val crosscompile = flavor == "windows" && os.isLinux && project.hasProperty("crosscompile")
val verifyFlavorConfiguration by tasks.registering {
when (flavor) {
"macos" -> if (!os.isMacOsX) throw IllegalArgumentException("Cross-compilation to MacOS is unsupported!")
"windows" -> if (!os.isWindows && !crosscompile) {
if (os.isLinux) throw IllegalArgumentException("Cross-compilation to Windows is not enabled, please do so to build this")
else throw IllegalArgumentException("Cross-compilation to Windows from this platform is unsupported!")
}
"linux" -> if (!os.isLinux) throw IllegalArgumentException("Cross-compilation to Linux is unsupported!")
else -> throw IllegalArgumentException("Unexpected flavor: $flavor")
}
}
tasks.runtime { dependsOn(verifyFlavorConfiguration) }
tasks.runtimeZip { dependsOn(verifyFlavorConfiguration) }
tasks.suggestModules { dependsOn(verifyFlavorConfiguration) }
tasks.jpackageImage { dependsOn(verifyFlavorConfiguration) }
tasks.jpackage { dependsOn(verifyFlavorConfiguration) }
if (crosscompile) System.setProperty("badass.runtime.jpackage.home", "/root/jpackage-win")
runtime {
if (crosscompile) javaHome.set("/root/jpackage-win")
addOptions(
"--strip-debug",
"--compress", "2",
"--no-header-files",
"--no-man-pages",
"--verbose"
)
if (crosscompile) targetPlatform("win", "/root/java")
jpackage {
imageName = application.applicationName
// vendor
when (flavor) {
"macos" -> {
installerType = "app-image"
installerOptions.addAll(listOf(
"--mac-package-name", "inceptum"
))
}
"windows" -> {
installerType = "msi"
installerOptions.addAll(listOf(
"--win-per-user-install",
"--win-dir-chooser",
"--win-menu",
"--win-upgrade-uuid", "180becd8-a867-40d4-86ef-20949cae68b5" // Update this UUID if you fork the project!!!
))
//imageOptions.add("--win-console") // Enable this for debugging
}
else -> {
// might also be able to push rpm with appropriate image
installerType = "deb"
installerOptions.addAll(listOf(
"--linux-package-name", "inceptum",
"--linux-shortcut"
))
}
}
}
}