如何使Maven Clean Install构建JavaFX8?

时间:2014-07-25 07:48:38

标签: maven javafx-8

每次我尝试运行我的JavaFX 8项目时,我都需要使用Maven进行全新安装,然后使用eclipse构建项目。仅执行全新安装将导致异常。

如何在一个命令中执行maven clean install和eclipse build。 如果我需要在我的pom.xml中添加它,我应该把它放在我的父pom.xml中还是全部放在它的子节点中?

谢谢!

2 个答案:

答案 0 :(得分:1)

最后我的工作,我刚刚在我的父pom.xml上添加了这行代码。

<build>
    <plugins>
        <!-- This will copy all your dependencies to target/libs, which will be 
            picked up by the ant task below -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}/libs</outputDirectory>
                        <includeScope>compile</includeScope>
                        <includeScope>runtime</includeScope>
                        <excludeArtifactIds>javafx</excludeArtifactIds>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
                <execution>
                    <id>create-javafx-packages</id>
                    <phase>package</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <target xmlns:fx="javafx:com.sun.javafx.tools.ant">
                            <taskdef uri="javafx:com.sun.javafx.tools.ant" resource="com/sun/javafx/tools/ant/antlib.xml" classpath="${javafx.tools.ant.jar}"/>
                            <fx:application id="fxApp" name="${project.name}" mainClass="${project.main.class}"/>
                            <!-- Note: this will overwrite the JAR produced by maven-jar-plugin, 
                                change destfile if you don't want this -->
                            <fx:jar destfile="${project.build.directory}/../../${project.build.finalName}">
                                <fx:application refid="fxApp"/>
                                <fx:fileset dir="${project.build.directory}/../.." includes="target/classes"/>
                                <fx:resources>
                                    <fx:fileset dir="${project.build.directory}/../.." includes="libs/*.jar"/>
                                </fx:resources>
                            </fx:jar>
                            <fx:deploy outdir="${project.build.directory}/../../javafx-output" outfile="${project.build.finalName}" nativeBundles="all">
                                <fx:application refid="fxApp"/>
                                <fx:resources>
                                    <!-- If you changed <fx:jar> above, don't forget to modify the 
                                        line below -->
                                    <fx:fileset dir="${project.build.directory}/../.." includes="${project.build.finalName}.jar"/>
                                    <fx:fileset dir="${project.build.directory}/../.." includes="libs/*.jar"/>
                                </fx:resources>
                            </fx:deploy>
                        </target>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>javafx</artifactId>
        <version>${javafx.version}</version>
        <scope>system</scope>
        <systemPath>${java.home}/lib/ext/jfxrt.jar</systemPath>
    </dependency>
</dependencies>

答案 1 :(得分:0)

尝试执行以下操作

mvn clean install eclipse:clean eclipse:eclipse然后在eclipse中对项目进行刷新。

HTH, Keshava。