openjdk-jfx
openjdk-jfx copied to clipboard
maven dependencies and jlink
The poms shipped with the artifacts on maven central show dependencies like:
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11.0.2</version>
<classifier>${javafx.platform}</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>11.0.2</version>
</dependency>
</dependencies>
When running the jlink maven plugin, this results in jlink trying to include modules javafx-graphics.jar
instead of javafx-graphics-platform.jar
and jlink fails with
Error: automatic module cannot be used with jlink: javafx.graphicsEmpty
Is there any reason not to include the platform classifier in all dependencies of javafx artifacts toward other javafx artifacts ?
As a workaround, I had to exclude the transitive dependencies in my project with configurations like :
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<classifier>linux</classifier>
<version>11.0.2</version>
<exclusions>
<exclusion>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
</exclusion>
</exclusions>
</dependency>
The javafx artifacts for each module like javafx.controls
come in an empty platform-neutral jar and up to three platform jars.
Notice, however, that there is only one pom per module. When calling the "empty" jar, the pom will resolve the platform (classifier, like javafx-controls:win
) and the module dependencies (like javafx.graphics
). For these dependencies, you will be resolving their pom, in the same way.
Adding the classifier to those dependencies, like:
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11.0.2</version>
<classifier>${javafx.platform}</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>11.0.2</version>
<classifier>${javafx.platform}</classifier> <--- This will be added
</dependency>
</dependencies>
won't necessary fix the issue, as you still have an empty "non-modular" jar for javafx-controls
in the first place.
You might want to have a look at the javafx-maven-plugin
: https://github.com/openjfx/javafx-maven-plugin. It does include a jlink
goal, and deals with the empty artifacts.
Sorry for not following up earlier. Since I have a working solution by excluding transitive dependencies this was not a priority for me.
I don't understand your point. The problem with jlink appears when there is a maven dependency towards the empty jar, since all dependency jars become JPMS modules in the module path. If you add the classifier line as suggested in the poms AND if the application pom declares dependency with the classifier, there won't be any empty jar in the dependency tree. And using the javafx-maven-plugin shouldn't be necessary. Am I wrong ?