简体   繁体   English

从 javafx maven 插件中排除依赖项

[英]Excluding dependencies from javafx maven plugin

I'm trying to use the maven shade plugin to make a cross platform fat jar for JavaFX.我正在尝试使用 maven shade 插件为 JavaFX 制作一个跨平台的 fat jar。

The shade plugin part works fine.阴影插件部分工作正常。 It runs off of the package goal, and it bundles the far jar properly.它超出了package的目标,并且正确地捆绑了远 jar。

The fat jar requires dependency classifiers to load in the appropriate platforms binary artifacts (shared libraries). fat jar 需要依赖分类器来加载适当的平台二进制工件(共享库)。

    <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 (ie the IDE) normally use the javafx-maven-plugin to run and debug the project.问题是我(即IDE)通常使用javafx-maven-plugin来运行和调试项目。 And when I have the classified dependencies in the pom, and try to run the project (ie mvn javafx:run) I get an exception: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found .当我在 pom 中有分类的依赖项并尝试运行项目(即 mvn javafx:ru​​n)时,我得到一个异常: 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. shade 插件能够包含和排除工件,但我没有看到 javafx 插件有类似的东西。 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.而且似乎shade插件依赖于全局依赖列表,所以我没有看到一种方法来单独为shade插件添加依赖项。 I also don't see an appropriate scope I could perhaps leverage to specify a dependency only for the package goal.我也没有看到一个合适的范围,我也许可以利用它来为package目标指定一个依赖项。

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.否则,我正在考虑简单地使用两个单独的 pom 来处理这个问题。 Perhaps that's the real solution.也许这才是真正的解决方案。

You can put this dependency in profile in your pom.xm file.您可以将此依赖项放在pom.xm文件中的配置文件中。 And active when needed.并在需要时主动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM