Skip to content

Instantly share code, notes, and snippets.

@dgreen

dgreen/nbactions.xml

Last active Oct 9, 2019
Embed
What would you like to do?
An attempt at a POM for NetBeans 11.1 (and CoolBeans) which allows building, debugging, testing, and creating javadoc style documentation.

Creating a JavaFX App for CoolBeans 2019.6 (Netbeans 11.1 and JavaFx 13)

This is a short note to document a process for creating a build environment in CoolBeans to

  • Build a modular project with JavaFx
  • Run project inside CoolBeans environment with the Run Project key (or from menu)
  • Debug project inside CoolBeans environment with the Debug Project key (or from menu)
  • Extract Javadoc documentation from the project with the Run | Generate Javadoc menu
  • Build an jlink image that can be run without installing other components (on the same OS as the build OS)
  1. Create project using the File | New Project menu, choose Java with Maven then Project from Archetype and then find the javafx-archetype-simple (or javafx-archetype-fxml), pick a project name and ensure you use an appropriate GroupId.
  2. Go to the Project tab on the left, and find the group Project Files under the new project. Open the pom.xml file and replace everything after line 10 (<maven.compiler.target>11</maven.compiler.target>) with everything after line 10 in gist pom file. Hit Save
  3. Go to File | Project Properties and go to the Run selection and place your fully-qualified main class in the Main Class text box. Hit OK.
  4. Set this project to be the main project by right-clicking on the project name and choosing Set as Main Project.
  5. Replace the nbactions.xml file that is now in the Project Files group with the one from the gist nbactions.xml file. Hit Save
  6. Select Run | Clean & Build. You may have to do this twice to resolve errors.
  7. Hit Run. Program should run and display a window with a bit of information. Close the window.
  8. Set a breakpoint on line 19 (var label = ...) in App.java. Choose Debug | Debug Main Project. It should stop at the breakpoint. Hit continue and you should see the program window. Close it. Clear the breakpoint.
  9. Choose Run | Generate Javadoc. Choose File tab in the upper left and go to target/site/apidocs/ and select index.html and right-click View. You should see an index of the project.
  10. While still in the files view, visit the folder jlink-image folder. Go to the bin directory, choose the file named after the project, right-click and select Run. The program should run and again show the window.
<?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 "${moduleName}/${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 "${moduleName}/${mainClass}"</exec.args>
<exec.executable>java</exec.executable>
<jpda.listen>true</jpda.listen>
</properties>
</action>
<action>
<actionName>javadoc</actionName>
<packagings>
<packaging>*</packaging>
</packagings>
<goals>
<goal>generate-sources</goal>
<goal>javadoc:javadoc</goal>
</goals>
</action>
</actions>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>edu.uab.dgreen</groupId>
<artifactId>fxdemo</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<moduleName>${project.groupId}.${project.artifactId}</moduleName>
<mainClass>${project.groupId}.${project.artifactId}.App</mainClass>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>13</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>13</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.1</version>
<scope>test</scope>
</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>${moduleName}</module>
</modules>
<launcher>
<name>${project.name}</name>
<module>${moduleName}/${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>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<source>11</source>
<target>11</target>
<sourceFileExcludes>**/module-info.java</sourceFileExcludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
@dgreen

This comment has been minimized.

Copy link
Owner Author

@dgreen dgreen commented Oct 8, 2019

Credits to:

  1. Mathew Dusome
  2. PowerStat on StackOverflow
  3. Geertjan Wielenga (for lots of pointers and willingness to help)
  4. Chris Luft
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment