JFXtras available in Sonatype OSS Repository

We have recently worked on a mavenization process of the JFXtras project to make it easily usable in a maven project. The project now has a pom and the current version (0.7-SNAPSHOT) is hosted at the Sonatype OSS repository.

To use JFXtras in your maven project, make sure that your maven environment has access to the Sonatype repository and just add the following dependencies to your pom:

EDIT: artifacts names have changed, they are now prepended with "jfxtras-"


Hope this helps using this great lib!

Unit testing your javafx application

In my last post I described how to set up a maven-javafx project using the jfrog-javafx plugin. One essential point was still missing in the configuration: the execution of javafx unit tests. By default, the jfrog-javafx plugin is not configured to handle a test folder. So let's see how to do that:
  • Create a src/test/javafx folder in your project
  • Put a unit test in this folder. Note that javafx does not support annotations, so the test must be written according to junit 3 rules. (however, you can use junit 4 in your dependencies, since it's backward compatible)
  • Update the configuration of the jfrog-javafx plugin to compile both the main and the test javafx folders. We define two executions for this plugin. The main execution will process the javafx resources and compile the javafx code in src/main/javafx during the compile phase. The test will compile the javafx code in src/test/javafx during the test-compile phase. You might also notice that junit is declared as a dependency of the plugin to fix a classpath issue since the jfrog-javafx plugin does not include the dependencies with test scope during compilation
  • Now your javafx test should be executed during the test phase of the maven lifecycle like a regular java unit test. You can now let hudson run your javafx unit tests at each build!

Spice up your JavaFX project with maven

Click here to download:
MavenFX.zip (7 KB)

JavaFX is a promising technology for nice Rich Internet Applications (RIA). However this is a quiet recent product (it was introduced by Sun at JavaOne, May 2007) and still lacks at integration with continuous development environments like hudson. Continuous integration is great because it reduces the gap between the development process and the release phase. With continuous integration, the work made by the developers is continuously compiled and tested against unit tests. This helps detecting many problems very early and simplifies the whole development process.

Hudson is an integration server that works very nicely with maven projects. So the first step to integrate a JavaFX project into our continuous integration environment was to "mavenize" the project. Jfrog has developed a javafx plugin for maven that integrates the compilation of the javafx sources into the maven lifecycle. Moreover it can generate a jnlp to launch the project. 

However, this plugin is by default configured to work with artifactory. For some reasons you might want to use it without artifactory, and that's possible. Just checkout the attached project to see how to configure it. Since artifactory takes care of some jnlp deployment issues, some additionnal plugins are required in this case: the dependency-plugin will copy the dependencies at the codebase directory of the jnlp and the jar-signer plugin will sign these jars.

At this step your project is fully integrated in the maven world. The last step is to deploy automatically the jnlp and required jars on a server to test your project. This can be achieved with the wagon plugin and its ftp extension (see attached project for an example of configuration). Then hudson can automatically deploy your application after each build by calling the mvn:deploy target. Enjoy!

Note: in the attached project, we use profiles (see profiles.xml) to configure the project dynamically whether this is intended to be run locally or deployed on a remote server. The "dev" profile allow you to run the project locally (using mvn clean package jfrog-javafx:excute) and the "prod" profile if for deployment (mvn -P-dev,prod deploy)

Synchronize maven and gae application version

We are currently developing a maven project deployed on google appengine.Maven manages a version property in its pom.xml:

When we release the project with maven (mvn release:prepare and mvn release:perform), this version number gets automatically increased to the next development version, for example from 0.0.1-SNAPSHOT to 0.0.2-SNAPSHOT.
The main problem is that google app engine uses another version descriptor in the appengine-web.xml file that is independent from the first one:

It would be great to get those to versions number synchronized! Here is a solution how to get it working:

  • Define a tiny groovy script, let's say utils.groovy, that will define a property defining the gae version. The problem is that we can't use the maven version directly since gae does not accept '.' and '-SNAPSHOT' in it's version. So this script will map the gae version to the maven version in that way:  X.Y.Z(-SNAPSHOT) -> X-Y-Z . Of course we will lose the SNAPSHOT information, but this is not really relevant in gae terms. Your application will be deployed at X-Y-Z.latest.myproject-site.appspot.com.

  • Attach the execution of the groovy script to the maven validate phase adding this to the pom.xml

  • This will define a maven property named gaeversion that you can use in your appengine-web.xml file

  • And finally tell to maven to filter our appengine-web.xml resource!