[英]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.