openjfx / javafx-maven-plugin

Maven plugin to run JavaFX 11+ applications
Apache License 2.0
371 stars 59 forks source link

Failed to build HelloFX for Windows on Arm64 platform #158

Open chirontt opened 2 years ago

chirontt commented 2 years ago

I've got an Arm64 machine running Windows 11 natively (Windows on Arm64). I've installed the OpenJDK for Windows on Arm64 from Microsoft, so Java is available natively on the machine (i.e. no emulation of x86_64 code.) Running the mvn --version command shows:

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: C:\apps\apache-maven-3.8.6
Java version: 17.0.4, vendor: Microsoft, runtime: C:\apps\jdk-17.0.4+8
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 11", version: "10.0", arch: "aarch64", family: "windows"

When I try to build the gluonhq/gluon-samples' HelloFX project, with the command mvn package, it fails to build:

[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< com.gluonhq.samples:hellofx >---------------------
[INFO] Building HelloFX 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.865 s
[INFO] Finished at: 2022-08-13T17:11:20-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project hellofx: Could not resolve dependencies for project com.gluonhq.samples:hellofx:jar:1.0.0-SNAPSHOT: The following artifacts could not be resolved: org.openjfx:javafx-controls:jar:${javafx.platform}:18.0.2, org.openjfx:javafx-graphics:jar:${javafx.platform}:18.0.2, org.openjfx:javafx-base:jar:${javafx.platform}:18.0.2: org.openjfx:javafx-controls:jar:${javafx.platform}:18.0.2 was not found in https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

I expect that the mvn package would at least compile and produce a jar package, even if the jar would fail to run afterwards because of missing JavaFX native libraries for Windows ARM64 platform in Maven Central. But the code fail to even compile, with above errors.

chirontt commented 2 years ago

Update: this plugin seems to try to set a value for some internal property javafx.platform, and it fails to set it for Windows on Arm64 platform, so my build fails with the above exception. I can "help" with the build command by explicitly specifying a known value for the property (any valid known value such as win, linux, or mac), like:

mvn package -Djavafx.platform=linux

and it works, producing the target\hellofx-1.0.0-SNAPSHOT.jar artifact.

The above jar can run fine in Windows on Arm64, by using a JDK distribution with embedded JavaFX, like the "Full JDK" distribution from BellSoft for Windows Arm.

Note that the hellofx app can be run with the Maven javafx:run task, like

mvn javafx:run -Djavafx.platform=linux

if the above-mentioned "Full JDK" is used to run it.