Task javaApplication

Build a Java-based macOS bundled applications and/or executable JAR. Basic and application JAR files may also be created.

Three options for bundled applications are supported:

  • Building an application for a single target architecture. By default, the application is built for the current execution environment.
  • Building multiple applications, one for each target architecture.
  • Building a single application that supports multiple target architectures.

Note that a multi-architecture application requires a custom launcher that knows how to find the appropriate Java runtime for the execution architecture.

By default, bundled applications created by this task use the screen menu bar and the system appearance. Use of the system appearance is required when using the VAqua look and feel, but is probably inappropriate otherwise. Both defaults can be overridden using explicit jvmArg elements.

Properties

Property Description Type
appname This property specifies the application name to use if no name is specified in the task definition. String
jdk_arm This property specifies the default JDK runtime to install in an arm64 application if no arm64 JDK is specified in the task definition. File
jdk_x86 This property specifies the default JDK runtime to install in an x86_64 application if no x86 JDK is specified in the task definition. File
jdk This property specifies the JDK runtime to install in a multi-architecture application if no generic JDK is specified in the task definition. File
dist_arm This property specifies the application installation directory to use for arm64-specific bundled applications if no arm64 application installation directory is specified in the task definition. File
dist_x86 This property specifies the application installation directory to use for x86-specific bundled applications if no x86 application installation directory is specified in the task definition. File
dist This property specifies the application installation directory for bundled applications that support multiple architectures or single architecture bundled applications when no architecture-specific output directory is specified in the task definition or via a property. File
jardist This property specifies the JAR installation directory to use if no valid JAR installation directory is specified in the task definition. File
workdir This property specifies a directory where intermediate work products should be written. If not defined, work products are stored in a directory named out in the build directory. File
classesdir This property specifies a directory containing class files to include in the application, unless includeStandardContents is false. File
javaLauncher This property specifies the Java launcher to use in the bundled application if no launcher is specified in the task definition. If neither option is specified, the default jpackage launcher is used. File
codeSignKey This property specifies a code signing key to use if no code signing key is specified in the task definition. If neither option is specified, code signing is not performed. String
universalApplication This property provides a default value for the similarly named attribute. boolean

References

Reference Description Type
jar.resources The ID of a resource collection whose contents are to be included in the application, unless includeStandardContents is false. ResourceCollection
application.default.tasks The ID of a task collection to be run at the start of this task. TaskCollection

Parameters accepted as attributes

Attribute Description Type Required?
mainclass Specify the fully qualified name of the application main class. String Yes.
applicationjarfilename Specify the name of the generated application JAR, without a suffix. This attribute is unsupported. String No.
attachable Specify whether the application permits being attached to a debugger. boolean No. Defaults to false.
codesigningkey Specify the key to use for signing code resources. String No.
dist Specify the directory to install the application. See the description of the dist property for details. File No.
dist_x86 Specify the directory to install an x86 application. See the description of the dist_x86 property for details. File No.
dist_arm Specify the directory to install an arm64 application. See the description of the dist_arm property for details. File No.
jdk Specify the location of a JDK to install in the application. See the description of the jdk property for details. File No.
jdk_x86 Specify the location of a JDK to install in an x86 application. See the description of the jdk_x86 property for details. File No.
jdk_arm Specify the location of a JDK to install in an arm64 application. See the description of the jdk_arm property for details. File No.
includestandardcontents Specify whether standard contents should be installed in the application. The contents are defined by a ResourceCollection whose ID is jar.resources. boolean No. Defaults to true.
universalapplication Specify whether to build a universal (x86 and arm64) application. Note that a multi-architecture application requires a custom launcher that knows how to find the appropriate Java runtime for the execution architecture. boolean No. Defaults to the value of the universalApplication property, or to false if the property is not defined.
arch Specify the target architecture(s) for the application. Note that a multi-architecture application requires a custom launcher that knows how to find the appropriate Java runtime for the execution architecture. String No. Defaults to the execution architecture, unless a universal application is requested.
installapplication Specify whether to create a bundled application. boolean No. Defaults to true.
installbasicjar Specify whether to create a basic JAR. The basic JAR contains the class trees and resources. boolean No. Defaults to true.
installexecutablejar Specify whether to create an executable JAR. The executable JAR contains the class trees, the resources, the required JAR files and dynamic libraries, and a Manifest that identifies the main class. boolean No. Defaults to false.
installapplicationjar Specify whether to create an application JAR. The application JAR contains the class trees, the resources, and the required JAR files. The application JAR is not executable, but it is appropriate for inclusion in a bundled application. boolean No. Defaults to true.
jardist Specify the directory where the basic JAR file should be installed. File No. If not specified, the value of the jardist property will be used. If no directory is specified or found, the basic JAR file will be installed in the jars subdirectory of the build directory.
basicjarmanifest Specify a manifest file to include in the basic JAR. File No. If not specified, the basic JAR will not include a manifest.
manifest Specify a manifest file to include in the application JAR or executable JAR. File No. If not specified, a simple manifest will be created.
launcher Specify the launcher program to include in the bundled application. Note that a multi-architecture application requires a custom launcher that knows how to find the appropriate Java runtime for the execution architecture. File No. If not specified, the default jpackage launcher is used.
applicationname Specify the application name. This name is stored in the bundled application and used when creating the name of the application bundle and other artifacts. It is displayed in the screen menu bar when the application is active. The name should be short. It must not be blank or contain a slash. String No. If not specified, the value of the appname property is used. If neither is default, the ant project name is used.
applicationsignature Specify the application signature to include in a generated property list for the application. This attribute is currently unsupported. String No.
splashfile Specify the (name) of an image to display while the bundled application is starting up. String No. If not specified, no splash screen will be automatically displayed for the application.
infoplist Specify an info.plist file to include in the bundled application. File No. If not specified, a file named package/macos/Info.plist in the build directory will be used. If no file is specified or found, a default info.plist file is created.
tooldist Specify the directory where an executable JAR should be installed, if one is requested. File No. If not specified and an executable JAR is requested, it will be installed in the build directory in the jars subdirectory.
vmsize Specify the virtual memory size for the bundled application. String No. If not specified, a default size is used.

Parameters accepted as nested elements

FileResource appInstall ...

Specify an additional install location for the bundled application. This location is used for applications that support multiple target architectures and for applications created using the default target architecture.

FileResource appInstallArm ...

Specify an additional install location for an arm64 bundled application.

FileResource appInstallIntel ...

Specify an additional install location for an x86 bundled application.

Argument jvmArg ...

Specify a command line argument to configure the Java virtual machine.

Argument arg ...

Specify a command line argument to pass to the application.

FileSet resource ...

Specify files to be included in the application. The files may include native libraries.

Path jar ...

Specify JARs required by the library for execution.

Path nativelibrary ...

Specify native libraries required by the library for execution.

Path framework ...

Specify Frameworks required by the library for execution.

ClassPath ...

Specify class trees and JARs required by the library for compilation and/or execution.