I would need some advice on how to troubleshoot this issue I'm having with my project, so there's not going to be a minimal reproducible code example, as it's not about the code itself.
Maven and Java are properly setup and working on all machines and OSes. Project was initially created with IntelliJ on Linux and working on any Linux machine without issues. However, trying to run mvn clean install
on Windows or macOS on the project will always result in the following error:
[ERROR] Failed to execute goal on project RNGame: Could not resolve dependencies for project com.ceebee:RNGame:jar:1.0-SNAPSHOT: The following artifacts could not be resolved: org.openjfx:javafx-controls:jar:${javafx.platform}:21.0.3 (absent), org.openjfx:javafx-graphics:jar:${javafx.platform}:21.0.3 (absent), org.openjfx:javafx-base:jar:${javafx.platform}:21.0.3 (absent), org.openjfx:javafx-fxml:jar:${javafx.platform}:21.0.3 (absent), org.openjfx:javafx-media:jar:${javafx.platform}:21.0.3 (absent): Could not find artifact org.openjfx:javafx-controls:jar:${javafx.platform}:21.0.3 in central (https://repo.maven.apache.org/maven2)
This is my current 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ceebee</groupId>
<artifactId>RNGame</artifactId>
<version>1.0-SNAPSHOT</version>
<name>RNGame</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.8.2</junit.version>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx</artifactId>
<version>21.0.3</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>21.0.3</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>21.0.3</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>21.0.3</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.32</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>20</source>
<target>20</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.32</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<executions>
<execution>
<!-- Default configuration for running with: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>com.ceebee.rngame/com.ceebee.rngame.RNGame</mainClass>
<launcher>RNGame.sh</launcher>
<jlinkZipName>RNGame</jlinkZipName>
<jlinkImageName>RNGame</jlinkImageName>
<stripDebug>true</stripDebug>
<stripJavaDebugAttributes>true</stripJavaDebugAttributes>
<noManPages>true</noManPages>
<stripDebug>true</stripDebug>
<noHeaderFiles>true</noHeaderFiles>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>copy-external-resources</id>
<phase>generate-sources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/res</outputDirectory>
<resources>
<resource>
<directory>res</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I'm on both macOS 13.4.1 and Windows 10. Here is the output of mvn --version
for mac including all necessary info:
Apache Maven 3.9.7 (8b094c9513efc1b9ce2d952b3b9c8eaedaf8cbf0) Maven home: /usr/local/Cellar/maven/3.9.7/libexec Java version: 21.0.3, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk/21.0.3/libexec/openjdk.jdk/Contents/Home Default locale: en_GB, platform encoding: UTF-8 OS name: "mac os x", version: "13.4.1", arch: "x86_64", family: "mac"
Maven version on Linux is 3.9.6. I haven't found much info on this particular issue online. My environments are set up all the same way on every machine. The project can be build just fine on any other Linux machine, but not Windows/macOS. The related JavaFX artifacts are being downloaded and are present in the .m2 directory, yet Maven can't seem to resolve them. There are no specific Maven settings in place. The hint about {javafx.platform}
doesn't help me much, as specifying this property as e.g. <classifier>mac</classifier>
doesn't help.
All setups are fresh on Windows/macOS with proper environment variables and java and mvn commands being recognised on the command line/terminal. Any pointers on how to go on about this issue would be appreciated.
org.openjfx:javafx-controls:jar:${javafx.platform}:21.0.3
it looks there is something wrong in your pom file ... best would be having a pom file.. – Sanjak<groupId>org.openjfx</groupId><artifactId>javafx</artifactId><version>21.0.3</version><type>pom</type>
. While it might work, I am not sure what purpose it serves and don't recommend it (other JavaFX projects I have seen don't do that). – Hillelmvn package
work? That would take a lot of the guesswork out of the problem. GenerationLost did you try the getting started That will generate a project with a pom and you should be able to build it with maven. You could modify the pom to have the correct javafx versions. I think you've improved the question by removing some of the information about the linux setups. – Equiponderancemvn package
ormvn install
. My project was generated by IntelliJ (an information I have removed from my OP) and I added dependencies to other FX artifacts as I needed them without prior issues. I was always able to build on Linux already. Creating new projects on e.g. macOS will result in the same issue when setting the JavaFX version to >=17. @Hillel removing the part you've mentioned unfortuntalely makes no difference, I've already tried that. – Infancymvn --version
including all necessary info:Apache Maven 3.9.7 (8b094c9513efc1b9ce2d952b3b9c8eaedaf8cbf0) Maven home: /usr/local/Cellar/maven/3.9.7/libexec Java version: 21.0.3, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk/21.0.3/libexec/openjdk.jdk/Contents/Home Default locale: en_GB, platform encoding: UTF-8 OS name: "mac os x", version: "13.4.1", arch: "x86_64", family: "mac"
. Let me know if you need any more info, will add this to OP. – Infancy/usr/local/opt/openjdk
, but it won't change the issue with maven. On Windows I've manually set up env variables to point to my local JDK and Maven, so that shouldn't be a problem. – Infancyjavafx-controls-22.0.1-mac.jar
among all other dependencies defined in the pom. – Infancyecho $M2_HOME
points to/Users/myusername/.m2
and I don't have a settings.xml in my .m2, so I assume the default settings are used, for which the repository is set toDefault: ${user.home}/.m2/repository
. This directory does indeed exist and holds the FX artifacts among other dependencies. – Infancy.m2
directory. It is a cache and will be recreated (you can check the contents after you rebuild and you see that it downloaded lots of stuff there). Doesn't sound like it will make much difference, but I guess you could try it in case there is some corrupted artifact or setting somewhere. Also, JavaFX caches some runtime stuff in ~/.openjfx, you could delete it too and it will be recreated, but again probably not your issue as that later cache is used at runtime, not build time. – Hillelmvn package -Djavafx.platform=mac
(or another appropriate classifier) will work-around this issue, i.e. explicitly set the unresolved property at the command line. – Hillel-Djavafx.platform=win
of course – Equiponderance