How to make Maven Clean Install build JavaFX8?

Every time I try to run my JavaFX 8 project, I need to do a clean install with Maven then build project with eclipse. Doing only the clean install will result in an Exception.

How can I make the maven clean install and eclipse build execute in one command. If I need to add it in my pom.xml, should I put it in my parent pom.xml or all in its children?

Thanks!

Upvotes: 1

Views: 1641

Answers (2)

Finally got mine working, I just added this lines of code on my parent 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>

Upvotes: 1

Keshava
Keshava

Reputation: 802

Try doing the following

mvn clean install eclipse:clean eclipse:eclipse and then do a refresh on the project in eclipse.

HTH, Keshava.

Upvotes: 0

Related Questions