/jpackage-gradle-plugin

JPackage Gradle Plugin

Primary LanguageKotlinBSD 2-Clause "Simplified" LicenseBSD-2-Clause

JPackage Gradle Plugin

Gradle plugin for jpackage tool available in JDK-14.

Gradle Plugin Portal BSD-2 license

This plugin will try to use jpackage executable from path specified by java.home system property.

Configuration

There are generic parameters as well as OS-specific parameters for OS X, Linux, Windows. Plugin determines OS name using os.name system property in order to configure OS-specific parameters.

OS-specific parameters should be conditionally specified for each required OS.

Example:

mac {
    icon = "icons/icons.icns"
}

windows {
    icon = "icons/icons.ico"
    winMenu = true
    winDirChooser = true
}

Generic Parameters

Parameter JPackage Argument
type --type <type>
appName --name <name>
appVersion --app-version <version>
destination --dest <destination path>
copyright --copyright <copyright string>
appDescription --description <description string>
vendor --vendor <vendor string>
runtimeImage --runtime-image <file path>
input --input <input path>
installDir --install-dir <file path>
module --module <module name>[/<main class>]
modulePath --module-path <module path>...
mainClass --main-class <class name>
mainJar --main-jar <main jar file>
icon --icon <icon file path>
verbose --verbose
arguments --arguments <main class arguments>

Windows Specific Parameters

Parameter jpackage argument
winMenu --win-menu
winDirChooser --win-dir-chooser
winUpgradeUuid --win-upgrade-uuid <id string>
winMenuGroup --win-menu-group <menu group name>
winShortcut --win-shortcut
winPerUserInstall --win-per-user-install

OS X Specific Parameters

Parameter jpackage argument
macPackageIdentifier --mac-package-identifier <ID string>
macPackageName --mac-package-name <name string>
macPackageSigningPrefix --mac-package-signing-prefix <prefix string>
macSign --mac-sign
macSigningKeychain --mac-signing-keychain <file path>
macSigningKeyUserName --mac-signing-key-user-name <team name>

Linux Specific Parameters

Parameter jpackage argument
linuxPackageName --linux-package-name <package name>
linuxDebMaintainer --linux-deb-maintainer <email address>
linuxMenuGroup --linux-menu-group <menu-group-name>
linuxRpmLicenseType --linux-rpm-license-type <type string>
linuxAppRelease --linux-app-release <release value>
linuxAppCategory --linux-app-category <category value>
linuxShortcut --linux-shortcut

Image Type

Plugin Value JPackage Type
DEFAULT Default image type, OS specific
APP_IMAGE app-image
DMG dmg
PKG pkg
EXE exe
MSI msi
RPM rpm
DEB deb

Default Command-Line Arguments

Default command line arguments are passed to the main class when the application is started without providing arguments. Each argument should be specified using <argument> configuration parameter.

Example:

argumens = listOf(
    "SomeArgument",
    "Argument with spaces",
    "Argument with \"quotes\""
)

Samples

Application image with full JRE

task("copyDependencies", Copy::class) {
    from(configurations.runtimeClasspath).into("$buildDir/jmods")
}

tasks.withType<org.panteleyev.jpackage.JPackageTask> {
    dependsOn("build")
    dependsOn("copyDependencies")

    appName = "Application Name"
    appVersion = project.version as String
    vendor = "app.org"
    copyright = "Copyright (c) 2020 Vendor"
    runtimeImage = System.getProperty("java.home")
    module = "org.app.module/org.app.MainClass"
    modulePath = "$buildDir/jmods"
    destination = "$buildDir/dist"
    javaOptions = listOf(
        "--enable-preview",
        "-Dfile.encoding=UTF-8"
    )

    mac {
        icon = "icons/icons.icns"
    }
    
    windows {
        icon = "icons/icons.ico"
        winMenu = true
        winDirChooser = true
    }
}

References

Packaging Tool User's Guide