I use the following with my students:
Changing to Maven
There are a few setting we will have to do to every program we make.

Under Project Files -> pom.xml
You must change everything under </organization> To this:

    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>11-ea+25</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-media</artifactId>
            <version>11-ea+25</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
          
            <!-- sets up the version of Java you are running and complines the 
Code -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <release>11</release>  
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.ow2.asm</groupId>
                        <artifactId>asm</artifactId>
                        <version>6.2.1</version> 
                    </dependency>
                </dependencies>
            </plugin>
           
            <!-- used to make the program run -->            
               <!-- used to make the program run -->            
             <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.6.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>${mainClass}</mainClass>
                </configuration>
            </plugin>   

           
            <!-- Adds the mainClass to the jar so it will run outside -->       
     
          <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>           
                    <archive>
                        <manifest>
                            <mainClass>${mainClass}</mainClass>
                        </manifest>
                    </archive>
                    <outputDirectory>
                        ${project.build.directory}/modules
                    </outputDirectory>
                </configuration>
            </plugin>

 <!-- Makes the jLink setup so you can give it to your friends 
            <plugin>
                <groupId>org.moditect</groupId>
                <artifactId>moditect-maven-plugin</artifactId>
                <version>1.0.0.Beta1</version>
                <executions>
                    <execution>
                        <id>create-runtime-image</id>
                        <phase>package</phase>
                        <goals>
                            <goal>create-runtime-image</goal>
                        </goals>
                        <configuration>
                            <modulePath>
                                <path>${project.build.directory}/modules</path>
                            </modulePath>
                            <modules>
                                <module>${project.groupId}</module>
                               
                            </modules>
                            <launcher>
                                <name>${project.name}</name>
                                <module>${project.groupId}/${mainClass}</module>
                            </launcher>
                            <compression>2</compression>
                            <stripDebug>true</stripDebug>
                            
<outputDirectory>${project.build.directory}/jlink-image</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
              -->
             <!-- Copies the depend FX files to your program  -->  
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.1.1</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            
<outputDirectory>${project.build.directory}/modules</outputDirectory>
                            <includeScope>runtime</includeScope>
                        </configuration>
                    </execution>
                </executions>
            </plugin> 
        </plugins>
    </build>
</project>
Change to nbactions.xml
In this file you are going to replace the whole thing with:

<?xml version="1.0" encoding="UTF-8"?>
<actions>
        <action>
            <actionName>run</actionName>
            <packagings>
                <packaging>jar</packaging>
            </packagings>
            <goals>
                <goal>process-classes</goal>
                <goal>package</goal>
                <goal>org.codehaus.mojo:exec-maven-plugin:exec</goal>
            </goals>
            <properties>
                <exec.args>--module-path "${project.build.directory}/modules" 
--module "${project.groupId}/${mainClass}"</exec.args>
                <exec.executable>java</exec.executable>
            </properties>
        </action>
        <action>
            <actionName>debug</actionName>
            <packagings>
                <packaging>jar</packaging>
            </packagings>
            <goals>
                <goal>process-classes</goal>
                <goal>package</goal>
                <goal>org.codehaus.mojo:exec-maven-plugin:exec</goal>
            </goals>
            <properties>
                
<exec.args>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} 
--module-path "${project.build.directory}/modules" --module 
"${project.groupId}/${mainClass}"</exec.args>
                <exec.executable>java</exec.executable>
                <jpda.listen>true</jpda.listen>
            </properties>
        </action>
    </actions>
In the Source Packages folder you need to make empty Java File and do not 
rename it. Afterwords rename it to module-info.java. Inside you need the 
following:

module dusome { 
requires javafx.fxml; 
requires javafx.controls; 
requires javafx.graphics; 
requires javafx.base; 
requires javafx.media; 
opens dusome.mjavafxtest; 
}

Where:

dusome --> is the groupId you setup for your programs
dusome.mjavafxtest --> is the name of the project you created.
When you want to make a copy of the program to give to your friends you must 
move --> from infront of <!-- Copies the depend FX files to your program --> 
and move it to the end of: <!-- Makes the jLink setup so you can give it to 
your friends

-----Original Message-----
From: Bob <bobsons...@yahoo.co.uk.INVALID> 
Sent: Sunday, November 25, 2018 11:19 AM
To: users@netbeans.apache.org
Subject: [javafx11][maven] Default JavaFX Maven build doesn't work for JDK 11

Using Apache Netbeans 10 to create a "Maven" -> "JavaFX Application" leads to a 
project which won't compile or run.

Have the default Maven project files been updated in Apache Netbeans 10 to work 
with JDK 11 and JavaFX? If not, can anyone point me to instructions for 
configuring the POM and the nbactions.xml file so that compile and run both 
work?

For what it's worth, I've followed numerous chunks of advice found online and I 
think I have the compilation step working now with the following dependencies 
added to the POM:

<dependencies>
     <dependency>
         <groupId>org.openjfx</groupId>
         <artifactId>javafx</artifactId>
         <version>11.0.1</version>
         <type>pom</type>
     </dependency>
     <dependency>
         <groupId>org.openjfx</groupId>
         <artifactId>javafx-base</artifactId>
         <version>11.0.1</version>
         <scope>compile</scope>
     </dependency>
     <dependency>
         <groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
         <version>11.0.1</version>
         <scope>compile</scope>
     </dependency>
     <dependency>
         <groupId>org.openjfx</groupId>
         <artifactId>javafx-fxml</artifactId>
         <version>11.0.1</version>
         <scope>compile</scope>
     </dependency>
</dependencies>

But calling on "Run" has led to a string of different problems, and currently 
my exec plugin configuration looks like this:

<plugin>
     <groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
     <version>1.6.0</version>
     <executions>
         <execution>
             <goals>
                 <goal>java</goal>
             </goals>
         </execution>
     </executions>
     <configuration>
         <executable>java</executable>
         <mainClass>MainApp</mainClass>
         <release>11</release>
     </configuration>
</plugin>

But this is obviously still wrong because "Run" leads to a usage advisory being 
dumped to the console:

--- exec-maven-plugin:1.6.0:exec (default-cli) @ ExchangeLogViewer ---
Usage: java [options] <mainclass> [args...]
            (to execute a class)

Has anyone got a recipe for a working Maven JavaFX 11 project in Apache 
Netbeans 10 already?

--

Bob


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org
For additional commands, e-mail: users-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org
For additional commands, e-mail: users-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to