我有一個JavaFx項目,我想減少到一個jar文件。 我的POM包含Java-FX插件:如何結合javafx-maven-plugin和maven-assembly-plugin?
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.1.4</version>
<configuration>
<mainClass>application.Main</mainClass>
<jfxAppOutputDir>${project.build.directory}/jfx/app</jfxAppOutputDir>
</configuration>
<executions>
<execution>
<id>create-jfxjar</id>
<phase>package</phase>
<goals>
<goal>build-jar</goal>
</goals>
</execution>
</executions>
</plugin>
和組裝插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<!-- get all project dependencies -->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<!-- MainClass in mainfest make a executable jar -->
<archive>
<manifest>
<mainClass>application.Main</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<!-- bind to the packaging phase -->
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
當我打電話「MVN套裝」一個jar文件將被建立,但它不包含JFX -jar文件,但包含某種「jar wihout jfx support」-version。 如何告訴Maven Assembly插件使用jfx插件(位於jfxAppOutputDir(../jfx/app/))中的jar版本?
你是什麼意思「jar沒有jfx支持」?由於是JavaFX應用程序,JAR不必包含任何特殊的內容。 maven-assembly-plugin對我來說工作正常(沒有javafx-maven-plugin) - 我使用的是2.6版本。有一件事可能與源代碼和目標JRE版本有關(在maven-compiler-plugin設置中)。 – Itai
我有兩個jar文件:一個在目標文件夾中,另一個在target/jfx/app文件夾中。 他們都是平等命名的。 如果我啓動目標版本,則會收到錯誤消息:「無主清單屬性」。 target/jfx/app中的版本正常工作。 –
您能否編輯您的問題以包含完整的'pom.xml',以及有問題的JAR中的清單文件?另外/或者 - 也許嘗試使用匯編插件版本2.6? – Itai