Class JPackageExtension

java.lang.Object
io.github.danlewis783.jpackage.JPackageExtension

public abstract class JPackageExtension extends Object
Configuration for packaging a Java application with the jpackage tool.
jpackage {
    appName = "MyApp"
    mainClass = "com.example.Main"
    icon = layout.projectDirectory.file("packaging/myapp.ico")
    docFiles.from("README.md", "LICENSE")
    installer {
        types = ["msi"]
    }
}
  • Constructor Summary

    Constructors
    Constructor
    Description
    JPackageExtension(org.gradle.api.model.ObjectFactory objects)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract org.gradle.api.provider.ListProperty<String>
    Modules linked into the generated runtime image (--add-modules).
    abstract org.gradle.api.provider.Property<String>
    Application name; also the launcher name.
    abstract org.gradle.api.provider.Property<String>
    Application version.
    abstract org.gradle.api.provider.ListProperty<String>
    Default command-line arguments passed to the main class (--arguments).
    abstract org.gradle.api.provider.Property<String>
    Copyright string embedded in the application.
    abstract org.gradle.api.provider.Property<String>
    Description shown in the app metadata and installers.
    abstract org.gradle.api.file.DirectoryProperty
    Local directory that jpackageInstall copies the application image into, for developer self-use without an installer.
    abstract org.gradle.api.file.ConfigurableFileCollection
    Documentation files (README, LICENSE, manuals, ...) copied into the root of the application image.
    abstract org.gradle.api.provider.ListProperty<String>
    Extra arguments appended verbatim to the app-image jpackage invocation.
    abstract org.gradle.api.file.RegularFileProperty
    Launcher icon (.ico on Windows, .icns on macOS, .png on Linux).
    Native installer options used by the jpackageInstaller task.
    abstract org.gradle.api.provider.ListProperty<String>
    JVM options baked into the launcher (--java-options).
    abstract org.gradle.api.provider.ListProperty<String>
    Options passed to jlink when the runtime image is generated (--jlink-options).
    abstract org.gradle.api.provider.Property<Integer>
    Java major version of the JDK toolchain whose jpackage tool is used.
    abstract org.gradle.api.provider.Property<String>
    Fully qualified main class of the application.
    abstract org.gradle.api.provider.Property<String>
    File name of the main jar within the packaged input.
    abstract org.gradle.api.file.DirectoryProperty
    Directory of resources that override jpackage defaults (--resource-dir).
    abstract org.gradle.api.file.DirectoryProperty
    A pre-built runtime image to bundle instead of one produced by jlink.
    abstract org.gradle.api.provider.Property<String>
    Vendor shown in the app metadata and installers.
    abstract org.gradle.api.provider.Property<Boolean>
    Passes --verbose to jpackage.
    abstract org.gradle.api.provider.Property<Boolean>
    When true on Windows, the launcher opens a console window and connects stdio.
    void
    installer(org.gradle.api.Action<? super InstallerOptions> action)
    Configures the native installer options.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JPackageExtension

      @Inject public JPackageExtension(org.gradle.api.model.ObjectFactory objects)
  • Method Details

    • getAppName

      public abstract org.gradle.api.provider.Property<String> getAppName()
      Application name; also the launcher name. Defaults to the project name.
    • getAppVersion

      public abstract org.gradle.api.provider.Property<String> getAppVersion()
      Application version. Defaults to the project version, or 1.0.0 when the project version is unspecified. Windows installers require a numeric x.y.z version.
    • getMainClass

      public abstract org.gradle.api.provider.Property<String> getMainClass()
      Fully qualified main class of the application. Required.
    • getMainJar

      public abstract org.gradle.api.provider.Property<String> getMainJar()
      File name of the main jar within the packaged input. Defaults to the archive file name of the jar task.
    • getVendor

      public abstract org.gradle.api.provider.Property<String> getVendor()
      Vendor shown in the app metadata and installers.
    • getDescription

      public abstract org.gradle.api.provider.Property<String> getDescription()
      Description shown in the app metadata and installers.
    • getCopyright

      public abstract org.gradle.api.provider.Property<String> getCopyright()
      Copyright string embedded in the application.
    • getIcon

      public abstract org.gradle.api.file.RegularFileProperty getIcon()
      Launcher icon (.ico on Windows, .icns on macOS, .png on Linux).
    • getWinConsole

      public abstract org.gradle.api.provider.Property<Boolean> getWinConsole()
      When true on Windows, the launcher opens a console window and connects stdio. Use for command-line applications. Defaults to false.
    • getJavaOptions

      public abstract org.gradle.api.provider.ListProperty<String> getJavaOptions()
      JVM options baked into the launcher (--java-options).
    • getArguments

      public abstract org.gradle.api.provider.ListProperty<String> getArguments()
      Default command-line arguments passed to the main class (--arguments).
    • getDocFiles

      public abstract org.gradle.api.file.ConfigurableFileCollection getDocFiles()
      Documentation files (README, LICENSE, manuals, ...) copied into the root of the application image. They end up in the zip, the dev install, and the installers.
    • getJpackageJdkVersion

      public abstract org.gradle.api.provider.Property<Integer> getJpackageJdkVersion()
      Java major version of the JDK toolchain whose jpackage tool is used. Defaults to the JVM running the build. This is independent of the Java version your application targets.
    • getRuntimeImage

      public abstract org.gradle.api.file.DirectoryProperty getRuntimeImage()
      A pre-built runtime image to bundle instead of one produced by jlink. Use this to ship a Java 8 JRE with an application that must run on exactly that runtime. Cannot be combined with addModules or jlinkOptions.
    • getAddModules

      public abstract org.gradle.api.provider.ListProperty<String> getAddModules()
      Modules linked into the generated runtime image (--add-modules). When empty, jpackage links its default module set, which is large; listing only what you need (for example ["java.desktop", "java.sql"]) makes the image much smaller.
    • getJlinkOptions

      public abstract org.gradle.api.provider.ListProperty<String> getJlinkOptions()
      Options passed to jlink when the runtime image is generated (--jlink-options).
    • getResourceDir

      public abstract org.gradle.api.file.DirectoryProperty getResourceDir()
      Directory of resources that override jpackage defaults (--resource-dir). On Windows this is where main.wxs, overrides.wxi, WiX fragment overrides, and <AppName>-post-image.wsf go — the hook for registry entries and custom install-time actions.
    • getExtraArgs

      public abstract org.gradle.api.provider.ListProperty<String> getExtraArgs()
      Extra arguments appended verbatim to the app-image jpackage invocation.
    • getVerbose

      public abstract org.gradle.api.provider.Property<Boolean> getVerbose()
      Passes --verbose to jpackage. Defaults to false.
    • getDevInstallDirectory

      public abstract org.gradle.api.file.DirectoryProperty getDevInstallDirectory()
      Local directory that jpackageInstall copies the application image into, for developer self-use without an installer. Defaults to <user home>/apps/<appName>. The task synchronizes the directory: files not part of the image are removed.
    • getInstaller

      public InstallerOptions getInstaller()
      Native installer options used by the jpackageInstaller task.
    • installer

      public void installer(org.gradle.api.Action<? super InstallerOptions> action)
      Configures the native installer options.