【发布时间】:2018-01-03 10:34:53
【问题描述】:
我正在尝试在 macos 上构建原生包并添加自定义图标而不是默认 java。
我将我的 128x128 icns 文件放在 src/main/deploy/package/macosx 中,在 pom.xml 中添加 javafx-maven-plugin 并运行命令 mvn jfx:build-native(或 mvn jfx:native)。什么也没有发生。意味着它已成功构建,但仍使用默认图标。我做错了什么?
这是我的 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>
而here 是我的项目结构的截图。
顺便说一句,我使用的是 IntelliJ IDEA 2017.1.4。我也看过这一系列的问题:
- JavaFX native bundle icon OS X
- including an icon into a self-contained JavaFX application (.exe) 我也尝试将 package/macosx 放在项目文件夹中,但没有成功。
- How to set custom icon for javafx native package icon on Windows
我还看到了在 NetBeansIDE 中完成此任务的一种简单方法(例如 here)。但我不想因为这么简单的问题而改变 IDE。 提前谢谢!
编辑 31.07
打开详细模式后,我发现它期待的是 Minesweeper-1.0.icns 而不是 Minesweeper.icns。在 javafx-maven-plugin 的配置中添加 appName 字段解决了我的问题。
【问题讨论】:
-
在 javafx-maven-plugin 配置块中有
<verbose>true</verbose>时,您的系统会写什么?请将此添加到您的问题中! (免责声明:我是 javafx-maven-plugin 的维护者) -
由于您尚未将 javafx-maven-plugin 配置为使用 maven-lifecycle 运行,因此您必须执行
mvn jfx:native而不是mvn jfx:build-native,最后一个仅在执行块内 -
肯定可以找到问题,如果我打开详细模式,谢谢!似乎它正在等待 Minesweeper-1.0.icns 作为图标,而我正在提供 Minesweeper.icns。
标签: maven intellij-idea javafx-8