我只是提出一个问题关于使用到的javafxpackager使JavaFX的罐子,你可以看到它在这里 。 我的问题是,我可以不包括在清单中的类路径。 好吧,在我等待的答案,我试着maven-antrun-plugin
代替。 它的工作很好,我可以运行我的依赖应用程序,但(总是有,但)只有依赖超出了我最后的罐子。 因此,它是这样的:
FinalJar.jar
lib
|_{all dependencies here}
我的清单文件指向通过依赖JavaFX-Class-Path
属性。 如果我把依赖罐子里面,就像我想,它没有找到我的依赖关系。 任何帮助吗?
编辑:这里的步骤依赖添加到瓶子,里面的pom.xml它:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>package</phase>
<configuration>
<target>
<taskdef name="jfxjar" classname="com.sun.javafx.tools.ant.FXJar"
classpathref="maven.plugin.classpath" />
<jfxjar
destfile="${project.build.directory}/dist/${project.build.finalName}">
<fileset dir="${project.build.directory}/classes" />
<!-- Adds the dependencies to jar -->
<fileset dir="${project.build.directory}/lib/" includes="*.jar" />
<application name="${project.name}" mainClass="com.google.code.mzplay.principal.PrincipalFX" />
<resources>
<!-- Adds the dependencies to classpath -->
<fileset dir="${project.build.directory}/lib/" includes="*.jar" />
</resources>
</jfxjar>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ant-javafx</artifactId>
<version>${javafx.version}</version>
<systemPath>${java.home}/../lib/ant-javafx.jar</systemPath>
<scope>system</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>javafx</artifactId>
<version>${javafx.version}</version>
<systemPath>${java.home}/lib/jfxrt.jar</systemPath>
<scope>system</scope>
</dependency>
</dependencies>
</plugin>
最后,该POM的我的“建造”的一部分成为本(你可以看到它有一个焊接部分也可以),其以来我用它很长一段时间,所以我不即使其确定知道了
<build>
<finalName>JarName</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.4</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>runtime</includeScope>
<outputDirectory>${project.build.directory}/dist/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>package</phase>
<configuration>
<target>
<taskdef name="jfxjar" classname="com.sun.javafx.tools.ant.FXJar"
classpathref="maven.plugin.classpath" />
<jfxjar
destfile="${project.build.directory}/dist/${project.build.finalName}">
<fileset dir="${project.build.directory}/classes" />
<application name="${project.name}" mainClass="com.google.code.mzplay.principal.WeldJavaFXLauncher" />
<resources>
<fileset dir="${project.build.directory}/dist/" includes="lib/*.jar" />
</resources>
</jfxjar>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ant-javafx</artifactId>
<version>${javafx.version}</version>
<systemPath>${java.home}/../lib/ant-javafx.jar</systemPath>
<scope>system</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>javafx</artifactId>
<version>${javafx.version}</version>
<systemPath>${java.home}/lib/jfxrt.jar</systemPath>
<scope>system</scope>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>[2.0,)</versionRange>
<goals>
<goal>copy-dependencies</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
这是很容易使用maven-shade-plugin
。 它建立里面所有依赖一个大胖子的罐子。 您可以结合使用javafx-maven-plugin
。 我也尝试过不同的方法和很长一段时间发挥,这解决方案是唯一一个真正的作品。 此外,很容易成立。
这里是你有什么要添加到您的pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<configuration>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>your.package.name.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.8.3</version>
<configuration>
<mainClass>your.package.name.Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
改变你的包名内mainClass
遮阳,也JavaFX插件和你做。 现在,您可以一如既往地构建应用程序mvn package
。
你想获得一些本地applictation? 像EXE或伤害。这是我的解决方案。 使项目作为Maven项目,然后再添加一些插件来击中目标; 我将分享我的pom.xml添加这两个插件在你的pom.xml,然后运行“MVN JFX:原生”在你以后终端。
<!-- this plugin will copy dependencies into target application-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<configuration>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.8.3</version>
<configuration>
<!-- it's javafx Application's Main Class -->
<mainClass>org.john.Main</mainClass>
<!-- what's platform , write what kind of target name -->
<bundler>exe</bundler>
<!-- tell plugin where the target save-->
<jfxAppOutputDir>${project.build.directory}/app</jfxAppOutputDir>
<nativeOutputDir>${project.build.directory}/native</nativeOutputDir>
<appName>Ticket</appName>
<vendor>www.kvcoogo.com</vendor>
</configuration>
</plugin>