Skip to content

gradlex-org/java-module-packaging

Repository files navigation

Java Module Packaging Gradle plugin

Build Status Gradle Plugin Portal

A Gradle plugin to package modular Java application as standalone bundles/installers for Windows, macOS and Linux with jpackage.

This plugin is maintained by me, Jendrik Johannes. I offer consulting and training for Gradle and/or the Java Module System - please reach out if you are interested. There is also my YouTube channel on Gradle topics.

If you have a suggestion or a question, please open an issue.

Java Modules with Gradle

If you plan to build Java Modules with Gradle, you should consider using these plugins on top of Gradle core:

Here is a sample that shows all plugins in combination.

In episodes 31, 32, 33 of Understanding Gradle I explain what these plugins do and why they are needed.

Full Java Module System Project Setup is a full-fledged Java Module System project setup using these plugins.

How to use?

For general information about how to structure Gradle builds and apply community plugins like this one to all subprojects you can check out my Understanding Gradle video series.

Plugin dependency

Add this to the build file of your convention plugin's build (e.g. build-logic/build.gradle(.kts) or buildSrc/build.gradle(.kts)).

dependencies {
    implementation("org.gradlex:java-module-packaging:0.1")
}

Apply and use the plugin

In your convention plugin, apply the plugin and configure the targets.

plugins {
    id("org.gradlex.java-module-packaging")
}

javaModulePackaging {
    target("windows") {
        operatingSystem = "windows"
        architecture = "x86-64"
    }
    target("ubuntu") {
        operatingSystem = "linux"
        architecture = "x86-64"
    }
    target("macos") {
        operatingSystem = "macos"
        architecture = "x86-64"
    }
    target("macosM1") {
        operatingSystem = "macos"
        architecture = "aarch64"
    }
}

How ot use?

You can now run target specific builds:

./gradlew assembleWindows

Using target specific variants of libraries (like JavaFX)

Running on GitHub Actions

Disclaimer

Gradle and the Gradle logo are trademarks of Gradle, Inc. The GradleX project is not endorsed by, affiliated with, or associated with Gradle or Gradle, Inc. in any way.

About

A Gradle plugin to package stand-alone Java applications for multiple operating systems and architectures with 'jpackage'.

Resources

License

Stars

Watchers

Forks

Packages

No packages published