Maven's goals around software project management and comprehension can benefit JavaScript projects. Some of the benefits that can be readily attained are: project versioning, automated testing; continuous integration; dependency management; packaging; and release management.
Javascript developers have created nice toolkits like QUnit and JsDocs to get a productive and controlled development environment. They also use libraries like jQuery for development, split code into fine grained scripts and use some assembly tools to create the released scripts.
The Javascript Maven Tools project brings together tools from many places and greatly reduces the burden on you to develop your Javascript library or application.
Your project configures one extension in a minimal pom file to enable javascript support:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>your groupid</groupId>
<artifactId>your artifact id</artifactId>
<version>your version</version>
<packaging>js</packaging>
<name>Some name</name>
<description>A really nice description</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<extensions>
<extension>
<groupId>org.codehaus.mojo</groupId>
<artifactId>javascript-maven-plugin</artifactId>
<version>2.0.0-alpha-1</version>
</extension>
</extensions>
</build>
</project>
Maven Javascript Tools and associated plugins use the following conventions for directory structure. Conforming with this layout will keep your POM files as simple as possible.
<project-root>/ | +- pom.xml | +- src/ | | | +- main/ | | | | | +- js/ (source location for Scripts) | | +- resources/ (source location for any static resources) | | | +- test/ | | | | | +- js/ (source location for test scripts) | | +- resources/ (source location for test resources) | | ...
Once you have your pom file and associated files then you can load your application into a web browser via http://localhost:8080/ using the following command:
mvn jetty:run
We recommend that you start with some of the provided template projects (archetypes) and then come back to this documentation.