Home > Mobile >  Excluding dependencies from javafx maven plugin
Excluding dependencies from javafx maven plugin

Time:07-12

I'm trying to use the maven shade plugin to make a cross platform fat jar for JavaFX.

The shade plugin part works fine. It runs off of the package goal, and it bundles the far jar properly.

The fat jar requires dependency classifiers to load in the appropriate platforms binary artifacts (shared libraries).

    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-graphics</artifactId>
        <version>${javafx.version}</version>
        <classifier>win</classifier>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-graphics</artifactId>
        <version>${javafx.version}</version>
        <classifier>linux</classifier>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-graphics</artifactId>
        <version>${javafx.version}</version>
        <classifier>mac</classifier>
    </dependency>

That all works fine.

The problem is that I (i.e. the IDE) normally use the javafx-maven-plugin to run and debug the project. And when I have the classified dependencies in the pom, and try to run the project (i.e. mvn javafx:run) I get an exception: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found.

So, I'm looking to somehow make the classified dependencies conditional. The shade plugin has the ability to include and exclude artifacts, but I don't see a similar thing for the javafx plugin. And it seems that the shade plugin relies on the global dependency list, so I don't see a way to add dependencies solely for the shade plugin. I also don't see an appropriate scope I could perhaps leverage to specify a dependency only for the package goal.

Perhaps that's the wrong approach, but that's what I've come up with so far.

Otherwise I'm considering simply having two separate poms to handle this. Perhaps that's the real solution.

CodePudding user response:

You can put this dependency in profile in your pom.xm file. And active when needed.

  • Related