What does it do?
The JavaFX maven plugin provides maven goals to manage JavaFX and/or WebStart based projects.
Web Start
This plugin also handles pure Java WebStart projects which do not include JavaFX code.
The goals allows you to "compile" JavaFX code, generate "jnlp" files, deploy it all on a Maven Repository Manager, and then "execute" the JNLP file with Java WebStart.
- The plugin will compile javafx source files without interfering with the java compiler. It activates the javafxc Ant task using the Maven model to fill the classpath and other parameters.
- All generated class files will be generated under the standard maven dir "target/classes" and so packaged and distributed by Maven automatically.
- The plugin will activate Velocity to generate a JNLP file out of the master template and all Maven model data (your project information) and especially maven runtime dependencies. The generated JNLP file will be distributed by Maven automatically.
Resources
- Example project FishSim using the plugin: fishsim subversion trunk
- How to build the FishSim Demo page with Artifactory WebStart add-on screencast
- Binaries distribution on JFrog public Artifactory repository jfrog-javafx-plugin
- The source code on JFrog subversion repository: jfrog-javafx-plugin
- The JIRA project for bug reports and next features: JFXCP
- The maven generated site: jfrog-javafx-plugin
Change List
- Version 1.1 : Compiled using JavaFX 1.2.1, and with 1.2.1 dependencies
- Version 1.0 : Final version with JavaFX 1.2
Activating the plugin
- Add the maven repositories for the plugin and JavaFX resources
If you are using Artifactory Online or Artifactory Standalone, just add the default jfrog-third-party-releases and jfrog-plugins-releases public remote repositories, and make sure they are part of the virtual repositories you are using for your Maven build.
In The FishSim example pom.xml there is a "jfrog" profile that defines the 2 repositories needed for building JavaFX applications with this plugin. The XML code to add to your settings.xml or pom.xml is:<repositories> <repository> <id>jfrog-third-party-releases</id> <name>The jfrog repository for 3rd party releases</name> <url>http://repo.jfrog.org/artifactory/third-party-releases-local</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>jfrog-plugins-releases</id> <name>The jfrog repository for plugins releases</name> <url>http://repo.jfrog.org/artifactory/plugins-releases-local</url> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories>
- Then add the following plugin to your pom.xml file:
<plugin> <groupId>org.jfrog.maven.plugins</groupId> <artifactId>jfrog-javafx-plugin</artifactId> <executions> <execution> <goals> <goal>resources</goal> <goal>compile</goal> <goal>jnlp</goal> </goals> </execution> </executions> </plugin>
And you are ready!
JavaFX dependencies has Maven2 POM declaration
To use javafx SDK jars in your project you need to declare the following dependencies in your POM file:
<dependencies> <dependency> <groupId>javafx</groupId> <artifactId>javafxrt</artifactId> <version>1.1.1</version> </dependency> <dependency> <groupId>javafx</groupId> <artifactId>javafxgui</artifactId> <version>1.1.1</version> </dependency> </dependencies>
Standard Configuration
There are multiple configuration parameters, but here is an overview:
<plugin> ... <configuration> <mavenStyleResourceLinks>true</mavenStyleResourceLinks> <attach>true</attach> <generateJavaFxJnlp>true</generateJavaFxJnlp> <jnlpRootPath>${artifactory.url}/webstart-dev</jnlpRootPath> <source>1.5</source> <target>1.5</target> <mainClass>fishsim.Main</mainClass> <j2seVersion>1.5+</j2seVersion> <generateJavaFxJnlp>true</generateJavaFxJnlp> </configuration> </plugin>
Goals and Parameters Details
"compile" goal "jfrog-javafx:compile"
The plugin execute the JavaFX compiler Ant task on the standard "src/main/javafx" source folder using the Maven compile scope classpath, and all the classes generated goes into the standard "target/classes".
Maven keep executing Java compiler on the standard "src/main/java" source folder. So, the same project can have fx and java files.
Name |
Type |
Description |
Default Value |
Mandatory |
---|---|---|---|---|
sourceDirectory |
File |
The source directory. |
${basedir}/src/main/javafx |
Yes |
outputDirectory |
String |
The output directory. |
${project.build.outputDirectory} |
Yes |
includes |
List<String> |
A list of inclusion filters for the compiler. |
|
No |
excludes |
List<String> |
A list of exclusion filters for the compiler. |
|
No |
debug |
boolean |
Whether to include debugging information in the compiled class files. |
true |
|
showDeprecation |
boolean |
Output source locations where deprecated APIs are used. |
false |
|
fork |
boolean |
Fork the compiler if true. |
true |
|
optimize |
boolean |
Optimize compiled code using the compiler's optimization methods. |
false |
|
source |
String |
The -source argument for the compiler. |
1.6 |
No |
target |
String |
The -target argument for the compiler. |
1.6 |
No |
executable |
String |
The javafxc executable to use when fork is true. |
|
No |
verbose |
boolean |
Print verbose output. If running in debug mode will be set to true. |
false |
|
"resources" goal "jfrog-javafx:resources"
The purpose of this goal is to copy the non javafx files from the standard source path "src/main/javafx" to the classes folder. This is equivalent to the following code:
<resource> <directory>${project.basedir}/src/main/javafx</directory> <excludes> <exclude>**/*.fx</exclude> </excludes> </resource>
So, If you wish to manage your resources folders with separating fx files and non fx files under resources you can remove this goal.
Name |
Type |
Description |
Default Value |
Mandatory |
---|---|---|---|---|
resourcesDirectory |
File |
The resources directory. |
${basedir}/src/main/javafx |
Yes |
"jnlp" goal "jfrog-javafx:jnlp"
Generate the JNLP files under "target/jnlp" folder based on the default templates (if not overriden by configuration), the standard POM model values and configuration parameters.
If "attach" is set to true, then Maven will install and deploy the generated JNLP files.
Name |
Type |
Description |
Default Value |
Mandatory |
---|---|---|---|---|
templateDirectory |
File |
Directory containing the jnlp template file. |
${project.basedir}/src/main/jnlp |
No |
templateFileName |
String |
The jnlp template file (relative to the template directory). If not set use the default jnlp template provided by the plugin. |
|
No |
targetDirectory |
File |
The target directory of the generated jnlp file. |
${project.build.directory}/jnlp |
Yes |
targetFileName |
String |
The target file name. |
templateFileName if provided, ${project.artifactId}.jnlp otherwise |
Yes |
mavenStyleResourceLinks |
boolean |
If set to true the jar resources href path will use maven layout. i.e., /groupId/artifactId/filename |
false |
|
offlineAllowed |
boolean |
Used as JNLP template parameter |
true |
|
allPermissions |
boolean |
Used as JNLP template parameter |
false |
|
j2seVersion |
String |
Used as JNLP template parameter |
1.5+ |
Yes |
javaVmArgs |
String |
Used as JNLP template parameter |
|
No |
mainJar |
String |
Group id and artifact id in the form of groupId:artifactId of the jar with the main class. If not specified and mainClass is specified the plugin will try to detect the main jar by reflection. |
current project groupId:artifactId |
mainJar or mainClass |
mainClass |
String |
Fully qualified name of the main class. If specified and mainJar is not specified the plugin will try to detect the main jar by reflection. |
||
attach |
boolean |
Whether to attach the generated jnlp file(s) to the deployable artifact list. |
false |
|
generateJavaFxJnlp |
boolean |
If true and using the default template, the plugin will also generate a jnlp file using the default javafx template. If attach is true the generated jnlp will be attached with the classifier 'browser'. |
false |
|
appletWidth |
int |
Used as JNLP JavaFX Applet template parameter |
600 |
No |
appletHeight |
int |
Used as JNLP JavaFX Applet template parameter |
400 |
No |
verbose |
boolean |
Print verbose output. If running in debug mode will be set to true. |
false |
|
excludes |
List<String> |
List of dependencies to exclude in the form of groupId:artifactId:version |
|
No |
additionalParameters |
Map<String, String> |
Additional key:value parameters that will be used in the template. XML will look like: <additionalParameters> <iconHref>acme.jpg</iconHref> <author>john doe</author> </additionalParameters> |
|
No |
"execute" goal "jfrog-javafx:execute"
Execute the generated and deployed JNLP file using Java WebStart.
This JavaFx Maven Plugin is not signing the created and dependant jars, so the local target folder cannot be executed as is.
Name |
Type |
Description |
Default Value |
Mandatory |
---|---|---|---|---|
jnlpFullPath |
String |
Jnlp file path to execute. Can be local or remote file. |
|
One of jnlpFullPath or jnlpRootPath |
jnlpRootPath |
String |
Folder root path to find the jnlp file. Can be local or remote file. Usually equal to webstart virtual repository of Artifactory as seen here |
|
One of jnlpFullPath or jnlpRootPath |
jnlpRelativePath |
String |
Relative path to jnlpRootPath pointing to the jnlp file. |
maven relative path |
No |
2 Comments
Andreas Liebelt
Hi. Nice work!
But, shouldn't the repository point to: http://repo.jfrog.org/artifactory/libs-releases-local/
instead of http://repo.jfrog.org/artifactory/third-party-releases-local/
The JavaFX code is located at libs not at third-party (e.g. javafxc 1.2.1).
My Maven only downloads the jars automatically if I use the libs repo.
Stefan Lecho
When I use the default template, the 'resources' part of the JNLP is generated correctly. When I specify a template file (which is a JNLP file), the generated JNLP file does not contain the 'resources' part. It contains an exact copy of the given template. Would it be possible to get more information about the structure of the template ?