Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/petr-panteleyev/jpackage-gradle-plugin

JPackage Gradle Plugin
https://github.com/petr-panteleyev/jpackage-gradle-plugin

gradle-plugin jpackage jpackage-gradle-plugin

Last synced: 3 days ago
JSON representation

JPackage Gradle Plugin

Awesome Lists containing this project

README

        

# JPackage Gradle Plugin

Gradle plugin for [jpackage](https://openjdk.java.net/jeps/343) tool available since JDK-14.

[![Gradle Plugin Portal](https://img.shields.io/maven-metadata/v/https/plugins.gradle.org/m2/org/panteleyev/jpackageplugin/org.panteleyev.jpackageplugin.gradle.plugin/maven-metadata.xml.svg?label=Gradle%20Plugin)](https://plugins.gradle.org/plugin/org.panteleyev.jpackageplugin)
[![Gradle](https://img.shields.io/badge/Gradle-7.4%2B-green)](https://gradle.org/)
[![Java](https://img.shields.io/badge/Java-8-orange?logo=java)](https://www.oracle.com/java/technologies/javase-downloads.html)
[![GitHub](https://img.shields.io/github/license/petr-panteleyev/jpackage-gradle-plugin)](LICENSE)

## Finding jpackage

Plugin searches for ```jpackage``` executable using the following priority list:

1. Configured toolchain

2. ```java.home``` system property.

## Configuration

There are generic ```jpackage``` parameters as well as OS-specific parameters for OS X, Linux, Windows.
OS-specific parameters are processed when build is done on the corresponding OS.

If some generic parameters should have different values based on OS then they should be placed into configuration blocks:

* windows
* mac
* linux

*Example:*

```kotlin
// Windows specific parameters will be processed only during Windows build
winMenu = true
winDirChooser = true

mac {
// Generic parameter value for OS X build
icon = "icons/icons.icns"
}

windows {
// Generic parameter value for Windows build
icon = "icons/icons.ico"
}
```

### Parameters

ParameterTypeJPackage ArgumentMin VersionMax Version
Generic
aboutUrlString--about-url <url>17*
addModulesList<String>--add-modules <module>[,<module>]14*
appDescriptionString--description <description string>14*
appContentList<String> (*)--app-content additional-content[,additional-content...]18*
appImageString (*)--app-image <name>14*
appNameString--name <name>14*
appVersionString--app-version <version>14*
argumentsList<String>--arguments <main class arguments>14*
bindServicesBoolean--bind-services1415
copyrightString--copyright <copyright string>14*
destinationString (*)--dest <destination path>14*
fileAssociationsList<String> (*)--file-associations <file association property file>14*
iconString (*)--icon <icon file path>14*
inputString (*)--input <input path>14*
installDirString--install-dir <file path>14*
javaOptionsList<String>--java-options <options>14*
jLinkOptionsList<String>--jlink-options <options>16*
launchersList<Launcher> (*)--add-launcher <name>=<property file>14*
launcherAsServiceBoolean--launcher-as-service19*
licenseFileString (*)--license-file <license file path>14*
mainClassString--main-class <class name>14*
mainJarString--main-jar <main jar file>14*
moduleString--module <module name>[/<main class>]14*
modulePathsList<String> (*)--module-path <module path>14*
resourceDirString (*)--resource-dir <resource dir path>14*
runtimeImageString (*)--runtime-image <file path>14*
tempString (*)--temp <temp dir path>14*
typeImageType--type <type>14*
vendorString--vendor <vendor string>14*
verboseBoolean--verbose14*

Windows
winConsoleBoolean--win-console14*
winDirChooserBoolean--win-dir-chooser14*
winHelpUrlString--win-help-url <url>17*
winMenuBoolean--win-menu14*
winMenuGroupString--win-menu-group <menu group name>14*
winPerUserInstallBoolean--win-per-user-install14*
winShortcutBoolean--win-shortcut14*
winShortcutPromptBoolean--win-shortcut-prompt17*
winUpdateUrlString--win-update-url <url>17*
winUpgradeUuidString--win-upgrade-uuid <id string>14*

OS X
macAppCategoryString-mac-app-category <category string>17*
macAppStoreBoolean--mac-app-store17*
macBundleSigningPrefixString--mac-bundle-signing-prefix <prefix string>1416
macDmgContentList<String> (*)--mac-dmg-content additional-content[,additional-content...]18*
macEntitlementsString (*)--mac-entitlements <file path>17*
macPackageIdentifierString--mac-package-identifier <ID string>14*
macPackageNameString--mac-package-name <name string>14*
macPackageSigningPrefixString--mac-package-signing-prefix <prefix string>17*
macSignBoolean--mac-sign14*
macSigningKeychainString (*)--mac-signing-keychain <file path>14*
macSigningKeyUserNameString--mac-signing-key-user-name <team name>14*

Linux
linuxAppCategoryString--linux-app-category <category value>14*
linuxAppReleaseString--linux-app-release <release value>14*
linuxDebMaintainerString--linux-deb-maintainer <email address>14*
linuxMenuGroupString--linux-menu-group <menu-group-name>14*
linuxPackageNameString--linux-package-name <package name>14*
linuxPackageDepsBoolean--linux-package-deps14*
linuxRpmLicenseTypeString--linux-rpm-license-type <type string>14*
linuxShortcutBoolean--linux-shortcut14*

(*) - these parameters represent file or directory path and are resolved relative to the project root unless
they contain an absolute path.

### 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.

_Example:_

```kotlin
arguments = listOf(
"SomeArgument",
"Argument with spaces",
"Argument with \"quotes\""
)
```

### JVM Options

Options that are passed to the JVM when the application is started.

_Example:_

```kotlin
javaOptions = listOf(
"-Xms2m",
"-Xmx10m"
)
```

### jlink options

Options that are passed to underlying jlink call.

_Example:_

```kotlin
jLinkOptions = listOf(
"--strip-native-commands",
"--strip-debug"
)
```

### jpackage Environment Variables

Optionally environment variables can be passed to ```jpackage``` executable process.

_Example:_

```kotlin
jpackageEnvironment = mapOf(
"GRADLE_DIR" to project.projectDir.absolutePath,
"BUILD_DIR" to project.buildDir.absolutePath
)
```

```null``` values as well as ```null``` or empty keys are ignored.

## Logging

Plugin uses ```LogLevel.INFO``` to print various information about toolchain, jpackage parameters, etc. Use gradle
option ```--info``` to check this output.

## Dry Run Mode

To execute plugin tasks in dry run mode without calling ```jpackage``` set property```jpackage.dryRun``` to true.

_Example:_

```shell
$ ./gradlew clean build jpackage --info -Djpackage.dryRun=true
```

## Configuration Cache

This plugin is not compatible with Gradle [configuration cache](https://docs.gradle.org/current/userguide/configuration_cache.html).

## Examples

* [Modular Application with Full Runtime](doc/examples/ModularFullRuntime.md)
* [Non-Modular Application](doc/examples/Non-ModularApplication.md)

## References

[Packaging Tool User's Guide](https://docs.oracle.com/en/java/javase/19/jpackage/packaging-tool-user-guide.pdf)