I’ve been using the JavaFX Gradle Plugin for this, but it has a few downsides. It doesn’t support specifying the correct dependency configurations (e.g. “api”, “implementation”) on a per-dependency basis. It also has no support for obtaining dependency variants for operating systems and architectures other than the one currently being used for the build, which I need to do in order to build distributions of my application for other platforms. Lastly, I’m thinking a ComponentMetadataRule may be a more performant and synergistic approach than the plugin’s current implementation. It seems more like the “right” way to do this. If I can get this to work I’m thinking to suggest it as an alternative approach for a future implementation of the JavaFX Gradle Plugin.
My alpha attempt is to simply add the missing classified native platform transient dependencies for each JavaFX component (e.g. “org.openjfx:javafx-base:19:win” for “org.openjfx:javafx-base:19”) for the current build OS and architecture (which I’ve even hardcoded rather than detected to start). As published, the classifiers for each native dependency declaration are ${javafx.platform} substitution variables for properties added by profiles in the parent POM, which I don’t believe Gradle understands and processes when resolving them.
I’ve reviewed the documentation extensively, but my initial ComponentMetadataRule attempt isn’t working. I’ve tried adding the native dependencies to the inferred “compile” and “runtime” variants for all the non-classified JavaFX components, but I’m still getting “Unresolved reference: javafx” errors trying to compile.
For reference: The JavaFX plugin now has such a rule, which can be used by applying the plugin or by just using the rule from the plugin without applying it fully:
One may write such a rule in a bit more compact way using the org.gradlex.jvm-dependency-conflict-resolution plugin, like this:
Thank you for following up on this. I finally got around to trying to update my project to the 0.1.0 version of the JavaFX Gradle Plugin. I ran into a couple issues that pushed me towards a slightly different approach. I’ve updated my original prototype with the approach I’m now using, and documented everything in the README: GitHub - ianbrandt/javafx-gradle-configuration.
Feedback welcomed. Of note, I didn’t pay any attention to backwards compatibility with past Gradle versions, nor to suitability for publishing as an independent plugin, as neither was necessary for my internal use case. If anything from my approach is seen as a potential improvement, I could file corresponding issues against the JavaFX Gradle Plugin proper.