简体   繁体   中英

javafx-maven-plugin mac pkg installer does not show app icon

I use the following maven plugin configuration on my mac to generate the native installers.

<plugin>
    <groupId>com.zenjava</groupId>
    <artifactId>javafx-maven-plugin</artifactId>
    <version>8.5.0</version>
    <configuration>
        <appName>${project.name}</appName>
        <title>${project.name}</title>
        <description>${project.description}</description>
        <vendor>example</vendor>
        <certCountry>com</certCountry>
        <mainClass>${mainClass}</mainClass>
        <needMenu>true</needMenu>
        <additionalAppResources>src/main/deploy/package/all</additionalAppResources>
        <bundleArguments>
            <icon.ico>src/main/resources/icons/Icon.ico</icon.ico>
            <icon.png>src/main/resources/icons/Icon_32.png</icon.png>
            <icon.icns>src/main/resources/icons/Icon.icns</icon.icns>
        </bundleArguments>
        <jfxMainAppJarName>${project.build.finalName}.jar</jfxMainAppJarName>
    </configuration>
</plugin>

The Example.app folder and the Example.dmg installer both show the correct app icon, but the Example.pkg installer shows the plain java jar image (1). How can change that image (1)?

Is it possible to change the small icon in the title bar (2) as well?

JavaFX PKG安装程序OSX

The folder structure of my project:

  • src
    • main
      • java
        • *.java
      • resources
        • icons
          • Icon.ico
          • Icon.icns
          • Icon_*.png
      • deploy
        • package
          • all
            • LICENSE
  • pom.xml

I tried with Oracle Java JDK 8 Update 40 and Update 101 (64bit)

See also: javafx-maven-plugin#224

To make it dedundant, I'm pasting the answer here too:

Hi there,

this is no bug, it is "just" undocumented (seems there are a lot of people who know this, or very few people who use this feature).

Please see the getConfig_BackgroundImage -method:

https://github.com/teamfx/openjfx-8u-dev-rt/blob/fd634925571310284b02d89ff512552e795ba5e8/modules/fxpackager/src/main/java/com/oracle/tools/packager/mac/MacPkgBundler.java#L192

private File getConfig_BackgroundImage(Map<String, ? super Object> params) {
    return new File(CONFIG_ROOT.fetchFrom(params), APP_NAME.fetchFrom(params) + "-background.png");
}

Please create some image and place it below src/main/deploy/package/macosx , it has to be PNG-fileformat. This file should be named ${project.name}-background.png to get fetched by the bundler.

This should have been printed out to you while having <verbose> set to true .

General advice: turn VERBOSE-switch on ;) the packager itself behaves different (like not removing the temporary created working-folder, making it possible to further adjust your stuff) and prints out more important debugging-stuff.

The verbose-hint is even mentioned in the official documentation: https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/self-contained-packaging.html#BCGHHDGC

Late reply, but if you still wonder how to change the small icon in the title bar (2) you can do that simply by right-clicking the pkg-file and choose Get Info in the menu, then you simply drag-and-drop your .icns-file on top of the current one next to the pkg name. This will change the pkg-icon and what is shown in the title bar during installation. This does not appear to break the product signature either which is good, see picture below...

在此处输入图片说明

To verify signature still holds after icon change:

spctl -a -v --type install MyAppName-1.0.pkg
MyAppName-1.0.pkg: accepted
source=Developer ID

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM