简体   繁体   English

将Javafx应用程序与Maven捆绑在一起时不必要的依赖关系

[英]Unnecessary dependencies when bundling javafx application with maven

I am building a JavaFX application with maven, using the javafx maven plugin. 我正在使用javafx maven插件使用maven构建JavaFX应用程序。 Now when I execute mvn jfx:jar , it copies a lot of unnecessary jars into the resulting lib dir, like: 现在,当我执行mvn jfx:jar ,它将许多不必要的jar复制到生成的lib目录中,例如:

  • ant-1.8.2.jar
  • maven-antrun-plugin-1.7.jar
  • maven-plugin-api-2.0.11.jar

and many more. 还有很多。 So, it's basically everything I use for compiling the application - but it's certainly not needed for running it. 因此,基本上,这就是我用于编译应用程序的所有内容-但运行它当然并不需要它。 I feel like I should add a <scope>compile</scope> somewhere in the POM, but the <plugin> element doesn't take one as child. 我觉得我应该在POM的某处添加<scope>compile</scope> ,但是<plugin>元素不会将其作为子元素。 How can I tell maven not to include the plugins I use for compilation in the lib directory created with mvn jfx:jar ? 我怎样才能告诉Maven在用mvn jfx:jar创建的lib目录中不包括我用于编译的插件?

Edit: here's the POM if it helps: 编辑:如果有帮助,这是POM:

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
     xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>org.flyx.dsa.heldendokument</groupId>
    <artifactId>parent</artifactId>
    <version>0.1-SNAPSHOT</version>
</parent>
<artifactId>gui</artifactId>
<version>0.1-SNAPSHOT</version>
<name>gui</name>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.yaml</groupId>
        <artifactId>snakeyaml</artifactId>
        <version>1.15</version>
    </dependency>
    <dependency>
        <groupId>org.flyx.dsa.heldendokument</groupId>
        <artifactId>generator</artifactId>
        <version>0.1-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>org.controlsfx</groupId>
        <artifactId>controlsfx</artifactId>
        <version>8.20.8</version>
    </dependency>
</dependencies>
<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>org.flyx.dsa.heldendokument.gui.App</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.zenjava</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>8.1.2</version>
                <configuration>
                    <mainClass>org.flyx.dsa.heldendokument.gui.App</mainClass>
                    <appName>DSA Heldendokument-Generator</appName>
                    <needMenu>false</needMenu>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <excludes>
                <exclude>aboutWindow.fxml</exclude>
            </excludes>
        </resource>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
            <includes>
                <include>aboutWindow.fxml</include>
            </includes>
        </resource>
    </resources>
</build>
</project>

I'm the maintainer of the javafx-maven-plugin. 我是javafx-maven-plugin的维护者。

As far as I can see, there is nothing wrong with your pom.xml, maybe this already works when you upgrade the plugin-version to current 8.1.5 ?! 据我所知,您的pom.xml没什么问题,当您将插件版本升级到当前的8.1.5时,这可能已经起作用了!

To make sure where some dependency come from, please call mvn dependency:tree , maybe it's your own dependency: 为了确保某些依赖来自哪里,请调用mvn dependency:tree ,也许是您自己的依赖:

<dependency>
    <groupId>org.flyx.dsa.heldendokument</groupId>
    <artifactId>generator</artifactId>
    <version>0.1-SNAPSHOT</version>
</dependency>

What confuses me: why are you putting "pluginManagement" inside your build instead just "plugins"? 令我感到困惑的是:为什么要在构建中放入“ pluginManagement”而不是“ plugins”?

暂无
暂无

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

相关问题 如何(安全地)删除Eclipse中不必要的Maven依赖项? - How to (safely) remove unnecessary Maven dependencies in Eclipse? 如何对捆绑JavaFX应用程序时创建的可执行启动程序进行代码签名? - How do I code-sign the executable launcher that is created when bundling a JavaFX application? maven项目中的javafx应用程序 - javafx application in maven project 将 JavaFX 库与 Maven 捆绑在可执行文件 JAR 中(用于 ZD523878810E1EA223819ZA2) - Bundling JavaFX Library with Maven in executable JAR (for Java 11+) 在 JavaFX 中使用 `start` 方法时主要是不必要的吗? - Is main unnecessary when using `start` method in JavaFX? "在使用 Maven 构建的 Swing 应用程序中运行 JavaFx 时缺少 SwingInterOpUtils" - Missing SwingInterOpUtils when running JavaFx in an Swing application build with Maven 在javafx应用程序中使用maven ant插件,如何在javaFX jar中添加依赖项。 仍面临类未找到异常 - Using maven ant plugin in javafx application, How to add Dependencies in javaFX jar. Still facing class not found exception Maven依赖关系管理不会创建不必要的依赖关系吗? - Doesn't Maven Dependency management create unnecessary dependencies? Maven3排除从父pom继承的不必要依赖项以进行分发吗? - Maven3 excludes unnecessary dependencies inherited from parent pom for distribution? 如何使用java 10在maven中添加javafx依赖项 - how to add javafx dependencies in maven with java 10
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM