Skip to content

Allow additional jlink arguments - #491

Merged
fvarrui merged 2 commits into
javapackager:develfrom
commi:configurable-jlink-args
Oct 5, 2026
Merged

fvarrui merged 2 commits into
javapackager:develfrom
commi:configurable-jlink-args

Conversation

@commi

@commi commi commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Our app only needs German and English, but a customized JRE always contains the locale data of every language: jdk.localedata is 21.5 MB of the image. jlink --include-locales would drop it, but there is no way to pass that option, because BundleJre builds the jlink command line from fixed arguments.

Measured on our app with JDK 17:

JRE                                                    on disk   zipped
full JRE                                               135 MB    44.9 MB
customizedJre, --compress=0 --include-locales=de,en     92 MB    32.9 MB

This PR adds an additionalJlinkArgs property for Maven and Gradle, appended to the jlink call:

<additionalJlinkArgs>
    <additionalJlinkArg>--include-locales=de,en</additionalJlinkArg>
</additionalJlinkArgs>

Since the arguments come last, a --compress given there also overrides the default --compress=2. That helps installers: an image compressed by jlink can't be compressed again by the zipball or installer. Nothing changes for existing builds.

commi and others added 2 commits October 5, 2026 11:51
- problem: a customized JRE can't be tuned, e.g. with --include-locales,
  and below JDK 21 its precompressed modules image makes zipballs and
  installers bigger than with no jlink compression
- cause: BundleJre builds the jlink command line from fixed arguments
- solution: new additionalJlinkArgs property, appended to the jlink call,
  so a --compress given there overrides the default one

Signed-off-by: Till Seifert <me@till-seifert.de>
@fvarrui
fvarrui merged commit 9df353a into javapackager:devel Oct 5, 2026
13 checks passed
fvarrui added a commit that referenced this pull request Oct 5, 2026
The merge of #491 brought back the running Java's version for the default
--compress=2. README: --include-locales needs jdk.localedata, and jlink
options depend on the packaging JDK version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fvarrui

fvarrui commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Merged, thanks Till! 🙏

Before merging I tested it with JDK 11, 17, 21 and 25 (Maven, GNU/Linux):

  • The arguments reach jlink and are applied: with --include-locales=en,es only the en/es locale data is left.
  • A --compress given there overrides the default one, as you said.
  • --include-locales fails unless jdk.localedata is in the image, and jdeps usually doesn't detect it, so it has to be added with additionalModules.
  • --compress=zip-N only works on JDK 21+; 0/1/2 work everywhere but are deprecated since 21.

I added both notes to the README. The tests also showed that a customized JRE failed on JDK 24+ builds without jmods (e.g. Temurin 25, JEP 493). That's fixed in devel now (jlink links from the run-time image), and the default --compress=2 is now decided by the packaging JDK's version instead of the running one.

It'll be in 2.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants