I’m back to working on FEST-JavaFX, an open source library for functional testing of JavaFX GUIs. To keep consistency with the rest of FEST modules, I decided to use Maven to compile and build the project.
I blogged some time ago how to compile JavaFX code with Maven. I wasn’t too happy with it, since it was verbose and I’d have to copy/paste the Ant build for every JavaFX project. I found JFrog’s JavaFX Maven plugin and gave it a try. Although configuration was easy, I couldn’t make it work.
The plugin expects the JavaFX jars to be installed in a local Maven repository. This is something that I don’t agree with, for the following reasons:
- I don’t see the point of having JavaFX jars in a Maven repository, since those jars cannot be distributed (per JavaFX’s license)
- Installing those jars in a local repository is easy but time-consuming: it needs to be done one by one
- So far, with each release, the number and some of the names of JavaFX jars change; I wouldn’t want to go through the process of installing them in a local repository every time there is a JavaFX release
Since Maven already supports creating plugins based on Ant, I just had to wrap my existing Ant script with a Maven plugin.
Creating the plugin was really easy, it took no more than 10 minutes. Maven’s documentation and online book are pretty good and they helped me a lot.
The main difference between FEST’s JavaFX Maven plugin and JFrog’s is that FEST’s does not require the JavaFX jars to be installed in a local repository. Instead, it uses an environment variable, JAVAFX_HOME, to locate the path of the JavaFX jars.
I just released version 0.1. Since it is a Maven plugin, I don’t think it is necessary to add a distribution file to the “downloads” page. The plugin can be obtained from our Maven repository.
The following example shows how to use the plugin to compile JavaFX source when the standard “compile” goal is executed:
<build> <plugins> <plugin> <groupId>org.easytesting</groupId> <artifactId>fest-javafx-maven</artifactId> <version>0.1</version> <executions> <execution> <phase>compile</phase> <goals> <goal>desktopCompile</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
Please note that it is not necessary to specify the JavaFX jars as project dependencies (at least I haven’t had to do it, so far.)
Currently the plugin has only one goal: “desktopCompile”, to compile JavaFX sources under the desktop profile. For more information about configuring the plugin, please visit the plugin’s homepage.
I originally created version 0.1 to satisfy the needs of the FEST-JavaFX project. There is a lot of room for improvement.
Please give the plugin a try. Feedback is always welcome! :)
As an additional note, the Silicon Valley JavaFX user’s group (SvJugFx) will be holding its first meeting, with a live streaming presentation from Richard Bair. The SvJugFx is organized by my good friend and FEST teammate Stephen Chin. See you there!