SkillAgentSearch skills...

JavaPackager

:package: Gradle/Maven plugin to package Java applications as native Windows, MacOS, or Linux executables and create installers for them.

Install / Use

/learn @javapackager/JavaPackager

README

JavaPackager

Maven Central GPL-3.0

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.

Project maintainers needed

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.

History

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.

Apps packaged with JavaPackager

How to use this plugin

Package your app with Maven

Add the following plugin tag to your pom.xml:

<plugin>
    <groupId>io.github.fvarrui</groupId>
    <artifactId>javapackager</artifactId>
    <version>{latest.version}</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>package</goal>
            </goals>
            <configuration>
                <!-- mandatory -->
                <mainClass>path.to.your.mainClass</mainClass>
                <!-- optional -->
                <bundleJre>true|false</bundleJre>
                <generateInstaller>true|false</generateInstaller>
                <administratorRequired>true|false</administratorRequired>
                <platform>auto|linux|mac|windows</platform>
                <additionalResources>
                    <additionalResource>file path</additionalResource>
                    <additionalResource>folder path</additionalResource>
                    <additionalResource>...</additionalResource>
                </additionalResources>
                <linuxConfig>...</linuxConfig>
                <macConfig>...</macConfig>
                <winConfig>...</winConfig>
                [...]
            </configuration>
        </execution>
    </executions>
</plugin>

[!tip] See Maven plugin configuration samples to know more.

And execute the next command in project's root folder:

mvn package

Package your app with Gradle

Apply 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 packageMyApp

Generated artifacts

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

Plugin configuration properties

| 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

View on GitHub
GitHub Stars1.2k
CategoryDevelopment
Updated4d ago
Forks147

Languages

Java

Security Score

100/100

Audited on Mar 27, 2026

No findings