Skip to content

Added support to add files to jpackage resources argument - #3647

Open
alchitry wants to merge 1 commit into
JetBrains:masterfrom
alchitry:support-jpack-resource-override
Open

Added support to add files to jpackage resources argument#3647
alchitry wants to merge 1 commit into
JetBrains:masterfrom
alchitry:support-jpack-resource-override

Conversation

@alchitry

@alchitry alchitry commented Sep 8, 2023

Copy link
Copy Markdown

I wanted to add a driver (udev rule) file to my Linux install and to do this I needed to override the postinst script that jpackage generates. This can be done by providing a postinst script in the directory pointed to by the --resource-dir flag.

This is currently not exposed and is used only by the MacOS target.

I added an override that allows a directory to be supplied to each OS target. It may be better if this could be specified for each TargetFormat type instead of per OS but I don't think it matters as I think jpackage will ignore the files it doesn't recognize.

See https://docs.oracle.com/en/java/javase/20/jpackage/override-jpackage-resources.html for the relavant reasons to override this.

@alchitry

alchitry commented Sep 8, 2023

Copy link
Copy Markdown
Author

I ended up writing a task to modify the generated deb instead as I think it is the more correct solution. I do think this addition could still be helpful for some use cases.

Amaan Marfatia (CloudyDino) added a commit to CloudyDino/compose-multiplatform that referenced this pull request May 28, 2026
jpackage's --resource-dir is the documented override mechanism for
packaging resources (DMG volume icon via <name>-volume.icns, DMG
background, Linux preinst/postinst scripts, WiX templates, ...), but
Compose fully owns that directory: AbstractJPackageTask clears it and
repopulates it with the generated Info.plist on every run, so users
have no supported way to contribute their own files to it.

Add a packagingResourcesRootDir DSL property, mirroring appResourcesRootDir
(with common/<os>/<os>-<arch> subdirectories). Its files are copied into
the jpackage resource dir after it is cleared but before the generated
Info.plist/product-def.plist are written, so the Compose-managed plists
always take precedence over user-supplied files.

This revives the approach a maintainer suggested on JetBrains#1843 and supersedes
the abandoned JetBrains#3647. Unlike JetBrains#1843 -- which repointed jpackageResources at
a Sync output and so had its files removed by clearDirs -- the files are
copied in after the clear, so nothing is wiped. Addresses CMP-2042,
CMP-6411, CMP-1972, CMP-9837.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant