Liberica Native Image Kit doesn’t include the HTML Viewer yet. And GraalVM has limitations too when talking about JavaFX, depending on what kind of libraries you are using under the hood. But again it is quite simple to generate with gradle packages for Windows, macOS, Linux. This one gives you an example fo one of my apps generating automatically a binary after running the “jpackage” task on a windows, macos or linux machine. Nothing to be changed on the script, it just needs to be run on the respective systems. You will get a pkg on macOS and an windows installer on Windows etc.
It even generates the online help with the build (vitepress) and uploads it. And it signs the macOS files with my certificates.
import org.apache.tools.ant.taskdefs.condition.Os
import org.gradle.internal.os.OperatingSystem
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
}
// Loading all necessary plugins
plugins {
id("java-library")
id("com.dipien.releaseshub.gradle.plugin") version "4.0.0"
// https://github.com/java9-modularity/gradle-modules-plugin
id("org.javamodularity.moduleplugin") version "1.8.12"
// https://github.com/openjfx/javafx-gradle-plugin
id("org.openjfx.javafxplugin") version "0.0.14"
// https://github.com/beryx/badass-jlink-plugin/
id("org.beryx.jlink") version "2.26.0"
// https://github.com/int128/gradle-ssh-plugin
id("org.hidetake.ssh") version "2.11.2"
}
repositories {
mavenLocal()
mavenCentral()
}
apply(plugin: "java")
// Loading all necessary properties from gradle.properties file
// Java Version to use
targetCompatibility = appJavaVersion.toString()
sourceCompatibility = appJavaVersion.toString()
var currentOS = OperatingSystem.current()
// Project meta data
project.description = appDescription
project.ext.buildDate = new Date()
project.version = appVersion
run {
jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005'
}
// Future dependencies to be added here
dependencies {
implementation "org.apache.commons:commons-lang3:3.12.0"
implementation "org.apache.poi:poi:5.2.3"
implementation "org.apache.poi:poi-ooxml:5.2.3"
implementation "org.apache.logging.log4j:log4j-core:2.20.0"
implementation "com.univocity:univocity-parsers:2.9.1"
implementation "org.controlsfx:controlsfx:11.1.2"
implementation "org.hsqldb:hsqldb:2.7.2"
}
if (Os.isFamily(Os.FAMILY_MAC)) {
remotes {
webServer {
host = "XXXXXXXXXXXX.de"
user = "XXXXXXXXXXXX"
identity = file("/Users/jmu/.ssh/id_rsa")
}
}
} else {
remotes {
webServer {
host = "XXXXXXXXXXXX.de"
user = "XXXXXXXXXXXX"
identity = file("C:\\Users\\jmu\\.ssh\\id_rsa")
}
}
}
tasks.register("deployOnlineHelp") {
doLast {
ssh.run {
session(remotes.webServer) {
remove "/var/www/html/csv-converter.teccompanion.com/dist"
put from: "${projectDir}/vitepress/.vitepress/dist/", into: "/var/www/html/csv-converter.teccompanion.com"
}
}
}
}
// JavaFX dependencies
javafx {
version = appJavaFxVersion.toString()
// Read all Java FX modules from the properties file
def mods = []
for (mod in appJavaFxModules.split(",")) {
mods.add(mod)
}
modules = mods
}
// Setting the environment
application {
mainModule = appMainModule
mainClass = appMainClass
}
// define a pre-build task to build the vitePress docs beforehand
tasks.register('vitePress', Exec) {
workingDir "${projectDir}/vitepress" // replace with your actual app path
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine "npm.cmd", "run", "docs:build"
} else {
commandLine "npm", "run", "docs:build"
}
}
// make this task a dependency of the build and the run task
deployOnlineHelp.dependsOn(vitePress)
jpackage.dependsOn(deployOnlineHelp)
// JLink for modular projects
jlink {
mergedModule {
requires "java.xml"
}
// Some default options
options.set(["--strip-debug", "--compress", "2", "--no-header-files", "--no-man-pages"])
launcher {
name = rootProject.name
jvmArgs = ["-p", ".", "-Djdk.gtk.version=2", "-DFile.encoding=UTF-8"]
}
// Pack it!
jpackage {
//Resolve the used operating system
targetPlatformName = ""
if (currentOS.macOsX) {
targetPlatformName = "mac"
} else if (currentOS.linux) {
targetPlatformName = "linux"
} else if (currentOS.windows) {
targetPlatformName = "win"
}
// Resource directory for native package overrides,
resourceDir = file(appResources)
java {
toolchain {
languageVersion = JavaLanguageVersion.of(appJavaVersion)
modularity.inferModulePath.set(true)
}
}
if (targetPlatformName == "mac") { // we are on mac
installerType = "pkg" // we want to have macOS PKG
}
if (targetPlatformName == "win") { // we are on Windows - msi for msi installer
installerType = "exe"
}
if (targetPlatformName == "linux") { // we are on linux
installerType = "deb"
}
// Add jpackage-specific options
installerOptions = ["--name", rootProject.name, // installer name
"--description", project.description,
"--copyright", appCopyright,
"--vendor", appVendor,]
// Add platform-specific options for the target image and for jpackage
if (installerType == "pkg") {
imageOptions += ["--mac-sign", "--icon", appResources + "icon.icns",
"--mac-package-name", "CSV Converter",
"--mac-package-signing-prefix", "com.teccompanion.csvconverter.common",
"--mac-signing-key-user-name", "Jeannot Muller (XXXXXXXXXXXX)",
"--mac-signing-keychain", "/Users/jmu/Library/Keychains/login.keychain-db"]
installerOptions += ["--license-file", appResources + "LICENSE-OS-Installer.txt",
"--mac-package-identifier", "com.teccompanion.csvconverter.common",
"--mac-sign",
"--mac-package-name", "CSV Converter",
"--mac-package-signing-prefix", "com.teccompanion.csvconverter.common",
"--mac-signing-key-user-name", "Jeannot Muller (XXXXXXXXXXXX)",
"--mac-signing-keychain", "/Users/jmu/Library/Keychains/login.keychain-db"]
}
if (installerType == "exe") {
icon = appResources + "icon.ico"
imageOptions += ["--icon", appResources + "icon.ico"]
installerOptions += ["--resource-dir", appResources]
installerOptions += ["--win-per-user-install", // Install only for current user
// "--win-console", // Shows what Java outputs to the console
//"--win-dir-chooser",
"--win-menu",
"--win-shortcut",]
}
if (installerType in ["deb", "rpm"]) {
imageOptions += ["--icon", appResources + "icon_256x256.png"]
installerOptions += ["--linux-menu-group",
"Tools",
"--linux-shortcut"]
}
if (installerType == "deb") {
installerOptions += ["--linux-deb-maintainer", appEmailAdress]
}
if (installerType == "rpm") {
installerOptions += ["--linux-rpm-license-type",
"GPLv3"]
}
}
}
This is the vitepress generated online help