Search code examples
javadeploymentpackingjava-14jpackage

JPackage copy files to the Resource folder of app before the DMG is created


I am using JPackage from Java 14 on MacOS and need to copy files to the MacOS and Resources folders of the app prior to building the DMG but do not see how. In the Packaging Tool User's Guide it mentions running a script from the resources folder named application-name-post-image.sh but that does not seem to happen.


Solution

  • To do this, you need to split up the process into 3 steps:

    1. jpackage invocation: Generate an app image - this is a directory containing all the things that would go in the .dmg bundle but as a regular directory
    2. file editing: Copy files to the Resources and MacOS folders in the app image
    3. jpackage invocation: Generate the final app dmg from the app image you have modified

    Please read section 5 of the JPackage user's guide which describes this process in further detail. Essentially, you'll need to make two jpackage calls, one for generating the app image and one for generating the final dmg file.

    Hope this helps!