:package: Gradle/Maven plugin to package Java applications as native Windows, MacOS, or Linux executables and create installers for them.
:package: Gradle/Maven plugin to package Java applications as native Windows, MacOS, or Linux executables and create installers for them.
JavaPackager is a hybrid plugin for Maven and Gradle which provides an easy way to package Java applications in native Windows, MacOS or GNU/Linux executables, and generate installers for them.
[!IMPORTANT] See JavaPackager changes and fixes.
This project has been actively maintained for many years, but due to lack of time, I can no longer dedicate the attention it deserves. To keep it alive and evolving, I’m looking for contributors to help with its maintenance.
:point_right: Join the discussion
Any help is welcome! Thank you for your support.
It was born while teaching to my students how to build and distribute their Java apps, and after seeing that a chain of several plugins was needed to achieve this task, I decided to develop a plugin :ring: to rule them all.
Add the following plugin tag to your pom.xml:
io.github.fvarrui
javapackager
{latest.version}
package
package
path.to.your.mainClass
true|false
true|false
true|false
auto|linux|mac|windows
file path
folder path
...
...
...
...
[...]
[!tip] See Maven plugin configuration samples to know more.
And execute the next command in project's root folder:
mvn packageApply JavaPackager plugin in build.gradle using legacy mode (because at the moment it's only available in Maven Central repository):
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'io.github.fvarrui:javapackager:{latest.version}'
}
}
apply plugin: 'io.github.fvarrui.javapackager.plugin'Create your packaging task:
task packageMyApp(type: io.github.fvarrui.javapackager.gradle.PackageTask, dependsOn: build) {
// mandatory
mainClass = 'path.to.your.mainClass'
// optional
bundleJre = true|false
generateInstaller = true|false
administratorRequired = true|false
platform = "auto"|"linux"|"mac"|"windows"
additionalResources = [ file('file path'), file('folder path'), ... ]
linuxConfig {
...
}
macConfig {
...
}
winConfig {
...
}
...
}[!TIP] See Gradle plugin configuration samples to know more.
And execute the next command in project's root folder:
gradle packageMyAppBy default it will generate next artifacts in ${outputDirectory} folder:
| Artifact | Description | Platform | Requires |
|---|---|---|---|
${name} |
Directory with native application and other assets. | All | |
${name}-${version}-runnable.jar |
Runnable JAR file. | All | |
${name}_${version}.AppImage |
AppImage package file. | GNU/Linux | FUSE 2 to run the app. |
${name}_${version}.deb |
DEB package file. | All | |
${name}_${version}.rpm |
RPM package file. | All | |
${name}_${version}.exe |
Setup file. | Windows | Inno Setup (iscc command must be in PATH variable) |
${name}_${version}.msi |
MSI installer file. | Windows | WiX Toolset (candle and light commands must be in PATH variable) |
${name}_${version}.msm |
MSI merge module file. | Windows | WiX Toolset ( candle and light commands must be in PATH variable) |
${name}_${version}.dmg |
Disk image file (uses hdiutil). | MacOS | |
${name}_${version}.pkg |
PKG installer file (uses pkgbuild). | MacOS | |
${name}-${version}-${platform}.zip |
Zipball containing generated directory ${name}. |
All | |
${name}-${version}-${platform}.tar.gz |
Compressed tarball containing generated directory ${name}. |
All | |
assets |
Directory with all intermediate files generated by JavaPackager. | All |
[!TIP] Inno Setup and WiX Toolset installation guide.
| Property | Mandatory | Default value | Description |
|---|---|---|---|
additionalModulePaths |
:x: | [] |
Additional module paths for jdeps. |
additionalModules |
:x: | [] |
Additional modules to the ones identified by jdeps or the specified with modules property. |
additionalResources |
:x: | [] |
Additional files and folders to include in the bundled app. |
arch |
:x: | ${os.arch} |
The dependency of some ArtifactGenerator objects in the process of making packages, such as GenerateDeb |
administratorRequired |
:x: | false |
App will run as administrator (with elevated privileges). |
assetsDir |
:x: | ${basedir}/assets or ${projectdir}/assets |
Assets location (icons and custom Velocity templates). |
bundleJre |
:x: | false |
Embeds a customized JRE with the app. |
classpath |
:x: | List of additional paths to JVM classpath, separated with ; (recommended) or :. |
|
copyDependencies |
:x: | true |
Bundles all dependencies (JAR files) with the app. |
createTarball |
:x: | false |
Bundles app folder in tarball. |
createZipball |
:x: | false |
Bundles app folder in zipball. |
customizedJre |
:x: | true |
No open issues yet, or sync has not completed.