2019年11月11日 | Leave a comment 来自 NetBeans 创建的 maven jfx 项目, 包含了打包 pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>demo</groupId> <artifactId>fx1</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <name>fx1</name> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <mainClass>demo.fx1.MainApp</mainClass> </properties> <organization> <!-- Used as the 'Vendor' for JNLP generation --> <name>Your Organisation</name> </organization> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.6</version> <executions> <execution> <id>unpack-dependencies</id> <phase>package</phase> <goals> <goal>unpack-dependencies</goal> </goals> <configuration> <excludeScope>system</excludeScope> <excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds> <outputDirectory>${project.build.directory}/classes</outputDirectory> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version> <executions> <execution> <id>unpack-dependencies</id> <phase>package</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>${java.home}/../bin/javafxpackager</executable> <arguments> <argument>-createjar</argument> <argument>-nocss2bin</argument> <argument>-appclass</argument> <argument>${mainClass}</argument> <argument>-srcdir</argument> <argument>${project.build.directory}/classes</argument> <argument>-outdir</argument> <argument>${project.build.directory}</argument> <argument>-outfile</argument> <argument>${project.build.finalName}.jar</argument> </arguments> </configuration> </execution> <execution> <id>default-cli</id> <goals> <goal>exec</goal> </goals> <configuration> <executable>${java.home}/bin/java</executable> <commandlineArgs>${runfx.args}</commandlineArgs> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> <compilerArguments> <bootclasspath>${sun.boot.class.path}${path.separator}${java.home}/lib/jfxrt.jar</bootclasspath> </compilerArguments> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.16</version> <configuration> <additionalClasspathElements> <additionalClasspathElement>${java.home}/lib/jfxrt.jar</additionalClasspathElement> </additionalClasspathElements> </configuration> </plugin> </plugins> </build> </project> 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 <?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>demo</groupId> <artifactId>fx1</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <name>fx1</name> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <mainClass>demo.fx1.MainApp</mainClass> </properties> <organization> <!-- Used as the 'Vendor' for JNLP generation --> <name>Your Organisation</name> </organization> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.6</version> <executions> <execution> <id>unpack-dependencies</id> <phase>package</phase> <goals> <goal>unpack-dependencies</goal> </goals> <configuration> <excludeScope>system</excludeScope> <excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds> <outputDirectory>${project.build.directory}/classes</outputDirectory> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version> <executions> <execution> <id>unpack-dependencies</id> <phase>package</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>${java.home}/../bin/javafxpackager</executable> <arguments> <argument>-createjar</argument> <argument>-nocss2bin</argument> <argument>-appclass</argument> <argument>${mainClass}</argument> <argument>-srcdir</argument> <argument>${project.build.directory}/classes</argument> <argument>-outdir</argument> <argument>${project.build.directory}</argument> <argument>-outfile</argument> <argument>${project.build.finalName}.jar</argument> </arguments> </configuration> </execution> <execution> <id>default-cli</id> <goals> <goal>exec</goal> </goals> <configuration> <executable>${java.home}/bin/java</executable> <commandlineArgs>${runfx.args}</commandlineArgs> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> <compilerArguments> <bootclasspath>${sun.boot.class.path}${path.separator}${java.home}/lib/jfxrt.jar</bootclasspath> </compilerArguments> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.16</version> <configuration> <additionalClasspathElements> <additionalClasspathElement>${java.home}/lib/jfxrt.jar</additionalClasspathElement> </additionalClasspathElements> </configuration> </plugin> </plugins> </build> </project>