Monday, December 30, 2013

netbeans 7.4 maven javafx project doesn't run

Executing a javafx/maven project in netbeans doesn't work. The fix is here:

https://netbeans.org/bugzilla/show_bug.cgi?id=233613

It involves changing the following two step:
Step 1: Add the following to the projects pom.xml file:

<execution>
    <id>default-cli</id>
    <goals>
        <goal>exec</goal>                            
    </goals>
    <configuration>
        <executable>java</executable>
        <commandlineArgs>${runfx.args}</commandlineArgs>
    </configuration>
</execution>

<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">
..

    </organization>

    <build>
        <plugins>

  ..
  ..
            <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</executable>
                            <commandlineArgs>${runfx.args}</commandlineArgs>
                        </configuration>
                    </execution>                    
                    
                </executions>  
            </plugin>
            <plugin>
   ..
            </plugin>
        </plugins>
    </build>
</project>

Step 2: Exchange the project's nbaction.xml with
<?xml version="1.0" encoding="UTF-8"?>
<actions>
    <action>
        <actionName>run</actionName>
        <goals>
            <goal>clean package</goal>
            <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
        </goals>
        <properties>
            <runfx.args>-jar ${project.build.directory}/${project.build.finalName}.jar</runfx.args>
            <skipTests>true</skipTests>
        </properties>
    </action>
    <action>
        <actionName>debug</actionName>
        <goals>
            <goal>clean package</goal>
            <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
        </goals>
        <properties>
            <runfx.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -jar ${project.build.directory}/${project.build.finalName}.jar</runfx.args>
            <skipTests>true</skipTests>
            <jpda.listen>true</jpda.listen>
        </properties>
    </action>        
</actions>

No comments:

Post a Comment