Javascript Maven Plugin Revamped

In the process of researching for the Engineering Better Javascript series, I ended up implementing some of my ideas to make them concrete. I've extended the existing Javascript Maven Tools to include a QUnit plugin and report integration, as well as added some integration tests to ensure that things are working as expected. I also added a javascript-project base parent, which takes some of the redundant code out of the POM for a Javascript project. The code is available on GitHub, here.

A good example project to check out is my ActivityStreams JS project. There are just a few things to notice.

In the pom.xml file the packaging type is 'javascript' and the parent project is 'javascript-project'. The former enables Javascript lifecycle phases and packaging, and which also allows Javascript dependencies which you can also notice in the pom.xml.

There is a profiles.xml file. This defines Sonatype OSS repositories, which is where this plugin and several 'vendor' Javascript libraries are deployed. Releases are eventually synced with Maven Central, but that hasn't happened yet. If you're using Maven 3, you need to copy the profiles to your settings.xml.

The source code to the project lives in src/main/javascript, and the QUnit tests live in src/test/javascript.

When you run 'mvn test' on the command line, all source and test source is copied to a work directory, where all dependencies are also expanded under the lib directory. These can be included by the test suites. After tests are completed, failures are recorded to target/surefire-reports/qunit.txt where they are placed into generated reports exactly as JUnit tests are for Java.

This project does not contain integration tests, but to the best of my knowledge it can easily be done using the Jetty plugin with an integration testing tool of your choice fairly easily. This is a feature I'd like to implement sooner rather than later.

All these tools also work for Webapp projects. I will write a short post about that when I have one working well. To see a sneak peak, check out the hi-og-integration branch of the Soashable OSW project.

This post is lacking on the theory and technical details behind this project, which I've been slower than I'd hoped to deliver. But it's a practical taste of what I've been doing in the past few weeks.