Download

Go here to download ready-to-run and source distributions of Jangaroo. more...

Tuesday, September 9, 2008

Sneak preview of the Jangaroo Maven plugin

Good news for Maven2 users: with the introduction of the jangaroo-maven-plugin, it will soon be easier than ever to compile Jangaroo sources as part of your build process.

The plugin is an alternative to the provided Ant task and will be part of the next Jangaroo tools release. In the meantime you can already try the 0.1.2-SNAPSHOT version from the Jangaroo snapshot repository. The following pom.xml demonstrates how to use the plugin to build the helloWorld example, which is included with the Jangaroo distribution. Simply create a file called pom.xml in the root directory of the example (the one containing the build.xml file) and paste the following to it:

<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/maven-v4_0_0.xsd">
<modelversion>4.0.0</modelversion>
<groupid>net.jangaroo.examples</groupid>
<artifactid>hello-world</artifactid>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>hello-world-example</name>

<pluginrepositories>
<pluginrepository>
<id>jangaroo</id>
<name>Jangaroo repository</name>
<url>http://repo.jangaroo.net/maven2</url>
</pluginrepository>
<pluginrepository>
<id>jangaroo-snapshots</id>
<name>Jangaroo repository</name>
<url>http://repo.jangaroo.net/maven2-snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginrepository>
</pluginrepositories>

<build>

<plugins>
<plugin>
<groupid>net.jangaroo</groupid>
<artifactid>jangaroo-maven-plugin</artifactid>
<version>0.1.2-SNAPSHOT</version>
<executions>
<execution>
<id>compile-jangaroo-sources</id>
<goals>
<goal>compile</goal>
<goal>copy-runtime</goal>
</goals>
<configuration>

<!-- Default output directory is
{project.build.directory}/${project.build.finalName}/js
-->
<outputdirectory>
${project.build.directory}/${project.build.finalName}
</outputdirectory>

<!-- All of the following configuration parameters are optional,
the values shown are the defaults.
-->
<sourcedirectory>
${basedir}/src/main/js2
</sourcedirectory>

<verbose>false</verbose>
<debug>true</debug>
<debuglevel>source</debuglevel>

</configuration>
</execution>
</executions>
</plugin>

<plugin>
<artifactid>maven-war-plugin</artifactid>
<version>2.1-alpha-2</version>
<configuration>
<failonmissingwebxml>false</failonmissingwebxml>
</configuration>
</plugin>

</plugins>

</build>
</project>

Two mojos are available and will usually be run together: compile and copy-runtime. The latter one extracts the Jangaroo runtime joo/Class.js to the output directory.

To build the project, run mvn package in the directory containing pom.xml. Obviously, a working Maven2 installation is required to do so.

We still have some important homework to do before the plugin will be released, such as serious documentation or an option to concatenate all compiled output files into one compact JavaScript file. However, feedback to the plugin at this early stage is higly welcome. Just drop a comment below.