javajavafxmaven-2ivymaven-central

Download JavaFX dependency using Ivy


I'm looking to fetch JavaFX from Maven Central using Ivy.

This works to get the Java dependencies, but not the native dependencies.

Expected:

Actual:

How do I also obtain the native components?

ivy.xml

<ivy-module version="2.0" xmlns:m="https://ant.apache.org/ivy/maven">
    <info organisation="org.my" module="my-proj"/>
    <dependencies>
        <dependency org="org.openjfx" name="javafx-graphics" rev="21.0.1" />
    </dependencies>
</ivy-module>
ivy && ls ~/.ivy2/cache/org.openjfx/javafx-graphics/jars
# javafx-graphics-21.0.1.jar

Here's the POM: https://repo1.maven.org/maven2/org/openjfx/javafx/20.0.1/javafx-20.0.1.pom

Related: How to make maven request the correct javafx dependancies on linux

I'm adding the maven-2 tag because Ivy uses the Maven 2 repositories:

With no specific settings, Ivy uses the Maven 2 repository to resolve the dependencies you declare in an Ivy file.


Solution

    1. First obtain the javafx.platform value of the native components from the POM.
    2. Ensure the ivy.xml is configured to use the correct xmlns:m.
    3. Add m:classifier="linux" (or linux-aarch64, mac-aarch64, etc).
    4. Native platform jars should show in .ivy2/cache

    ivy.xml

    <ivy-module version="2.0" xmlns:m="https://ant.apache.org/ivy/maven">
        <info organisation="org.my" module="my-proj"/>
        <dependencies>
            <dependency org="org.openjfx" name="javafx-graphics" rev="21.0.1" />
            <dependency org="org.openjfx" name="javafx-graphics" rev="21.0.1" m:classifier="linux"/>
        </dependencies>
    </ivy-module>
    
    ls ~/.ivy2/cache/org.openjfx/javafx-graphics/jars
    # javafx-graphics-21.0.1.jar
    # javafx-graphics-21.0.1-linux.jar