Using Dojo with Maven
Submitted by gregw on Fri, 07/11/2008 - 01:23.
Using maven to build your project is a fantastic for managing your dependencies and avoiding having dependencies (and their dependencies) checked into your own svn. There are maven repositories for dojo snapshots and releases at:
These repositories contain artifacts for:
- dojo toolkit release as a zip, tar.gz and tar.bz2
- dojo toolkit packaged as a java war file ready to serve. The war includes a filter that sets the Cache-Control header to encourage browser caching.
- cometd artifacts for java API and cometd example war
Building Dojo with Maven
To checkout and build dojo with maven is as simple as:
svn co http://svn.dojotoolkit.org/src/view/anon/all/trunk dojo
cd dojo/util/maven
mvn
This will build the standard dojo release and package it as a zip, a tar.gz and tar.gz2 and make them available in your local repository. The groupId is org.dojotoolkit and the artifactId is dojo.
Using Dojo artifacts
The following incantation of the maven dependency plugin will download and unpack these artifacts into your maven project:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack dojo</id>
<phase>generate-sources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.dojotoolkit</groupId>
<artifactId>dojo</artifactId>
<version>${project.version}</version>
<type>zip</type>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/dojo</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Using Dojo in a WAR
A WAR file is a standard packaging of a java web application for a java servlet server. Along with the build of the dojo release artifacts, dojo is also packaged as a war file with groupId org.dojotoolkit and artifactId dojo-war. The war produced by this can be directly deployed and used by other web applications on the same server (there is no requirement for js to be served from the same war as your application). Alternately, this war can be used as an overlay by the maven war plugin and merged with your own war project:
<project xmlns="...">
<modelVersion>4.0.0</modelVersion>
<groupId>vom.acme</groupId>
<artifactId>myproject</artifactId>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<overlays>
<overlay></overlay>
<overlay>
<groupId>org.dojotoolkit</groupId>
<artifactId>dojo-war</artifactId>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</overlay>
</overlays>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.dojotoolkit.java</groupId>
<artifactId>dojo</artifactId>
<version>1.2-SNAPSHOT</version>
<type>war</type>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
Using Maven Repositories
Eventually the dojo maven release repositorie will be mirrored in the central maven repository. Until that time, or if you wish to use snapshots, you can access the dojo repositories directly with the following incantation in your pom.xml:
<repositories>
<repository>
<id>dojo</id>
<name>Dojo Maven2 Repository</name>
<url>http://download.dojotoolkit.org/maven2</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<layout>default</layout>
</repository>
<repository>
<id>dojoSnapshots</id>
<name>Dojo Maven2 Snapshot Repository</name>
<url>http://download.dojotoolkit.org/maven2-snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
<layout>default</layout>
</repository>
</repositories>
- Printer-friendly version
- Login or register to post comments
- Subscribe post
