0

I'm trying to build a native bundle on macos and add a custom icon instead of default java.

I put my 128x128 icns file in src/main/deploy/package/macosx, add javafx-maven-plugin in pom.xml and run command mvn jfx:build-native (or mvn jfx:native). And nothing happens. Meaning it is successfully built, but still uses default icon. What am I'm doing wrong?

Here is my pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>StarWars</groupId>
    <artifactId>Minesweeper</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <mainClass>example.minesweeper.Main</mainClass>
        <application.title>${project.artifactId}</application.title>
        <copyright>Han Solo</copyright>
    </properties>

    <organization>
        <name>Star Wars</name>
    </organization>

    <name>Minesweeper</name>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.testfx</groupId>
            <artifactId>testfx-core</artifactId>
            <version>4.0.6-alpha</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testfx</groupId>
            <artifactId>testfx-junit</artifactId>
            <version>4.0.6-alpha</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.zenjava</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>8.8.3</version>
                <configuration>
                    <vendor>AndreySerebryanskiy</vendor>
                    <mainClass>example.minesweeper.Main</mainClass>
                    <deployDir>${project.basedir}/src/main/deploy</deployDir>
                </configuration>
            </plugin>
        </plugins>


    </build>


</project>

And here is a screenshot of my project structure.

By the way, I'm using IntelliJ IDEA 2017.1.4. I also have seen this range of questions:

  1. JavaFX native bundle icon OS X
  2. including an icon into a self-contained JavaFX application (.exe) I also tried to put package/macosx in the project folder but it didn't work.
  3. How to set custom icon for javafx native package icon on Windows

I also saw a simple way of accomplishing this task in NetBeansIDE (for example here). But I do not want to change IDE because of such simple issue. Thank you in advance!

Edit 31.07

After turning verbose mode on I found that it was expecting Minesweeper-1.0.icns instead of Minesweeper.icns. Adding appName field in conficurations of javafx-maven-plugin solved my problem.

  • What does your system write, when having `true` inside the javafx-maven-plugin configuration-block? Please add this to your question! (**Disclaimer:** I'm the maintainer of the javafx-maven-plugin) – FibreFoX Jul 28 '17 at 21:18
  • as you haven't configured the javafx-maven-plugin to run with maven-lifecycle, you will have to execute `mvn jfx:native` and not `mvn jfx:build-native`, that last one is only within execution-blocks – FibreFoX Jul 28 '17 at 21:20
  • Definitely, problem could be found, if I turn on verbose mode, thank you! It appeared that it was waiting for Minesweeper-1.0.icns as an icon and I was providing Minesweeper.icns. – Andrey Serebryanskiy Jul 31 '17 at 12:02

1 Answers1

0

You will have to add to your javafx-maven-plugin configuration.

        <plugin>
            <groupId>com.zenjava</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>8.8.3</version>
            <configuration>
                <vendor>AndreySerebryanskiy</vendor>
                <mainClass>example.minesweeper.Main</mainClass>
                <deployDir>${project.basedir}/src/main/deploy</deployDir>
                <verbose>true</verbose><!-- always a good idea to have this set to true while debugging -->
                <appName>Minesweeper</appName>
            </configuration>
        </plugin>

Please make sure your ICNS-filename is the same as inside <appName>, then just call mvn jfx:native to have your application bundled.

FibreFoX
  • 2,858
  • 1
  • 19
  • 41