Gradle Multi-Project
jbundle automatically detects and handles Gradle multi-project builds with multiple application subprojects.
How It Works
When jbundle detects settings.gradle.kts (or .gradle), it:
Parses included subprojects
Scans each for the
applicationpluginExtracts
mainClass,mainModule, andaddModulesconfigurationOffers selection or builds all with
--all
Detection
jbundle looks for these patterns in build.gradle.kts:
plugins {
id("application")
}
application {
mainClass.set("com.example.Main")
}And module configuration:
Single Subproject
Interactive Selection
When multiple application subprojects exist:
CLI Flag
Skip the prompt with --gradle-project:
Configuration File
Set default in jbundle.toml:
All Subprojects
Build every application subproject with --all:
Each binary is placed in {output}/{subproject-name}:
Module Handling
Automatic Detection
jbundle combines:
jdeps analysis — Scans JAR for required modules
Gradle config — Extracts
addModules.add(...)from build files
Both are merged and deduplicated for the jlink runtime.
Manual Override
Bypass automatic detection with --modules:
Or in configuration:
Reusing Existing Runtime
If Gradle already built a jlink image, skip the jlink step:
Common locations jbundle checks:
{subproject}/build/jlink/{subproject}/build/image/{subproject}/build/jpackage/images/app-image/
Build Process
For subprojects, jbundle runs:
:{subproject}:shadowJar(preferred, produces fat JAR)Falls back to
:{subproject}:buildif shadowJar unavailable
Then looks for JAR in:
{subproject}/build/libs/*-all.jar{subproject}/build/libs/*-uber.jar{subproject}/build/libs/*.jar
Configuration Reference
New options for multi-project builds:
CLI Flags
--gradle-project <NAME>
Build specific subproject
--all
Build all application subprojects
--build-args <ARGS>
Extra arguments passed to Gradle (e.g., -P flags)
--modules <LIST>
Manual module list (comma-separated)
--jlink-runtime <PATH>
Reuse existing jlink runtime
jbundle.toml
Examples
Simple Multi-Project
With Custom Modules
Reusing Gradle's jlink
Troubleshooting
"No application subproject found"
Check that subprojects have the application plugin applied:
"Subproject 'x' not found"
Verify the subproject name matches what's in settings.gradle.kts:
Module errors at runtime
If the app fails with java.lang.module errors, modules are missing. Use --modules to add them:
shadowJar not available
If your project doesn't use Shadow plugin, ensure the regular build produces a fat JAR with all dependencies bundled.
Last updated
Was this helpful?