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.  The only fly in the ointment, is projects that don’t publish maven artifacts, and the Ajax dojo toolkit has been one of these. Until now that is ! 
I have added a maven build to dojo and created maven repositories for 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
However, if you are a “from first principals” type, then to checkout and build dojo is now as simple as:
svn co http://svn.dojotoolkit.org/src/view/anon/all/trunk dojocd dojo/util/mavenmvn
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. 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>
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</groupId>      <artifactId>dojo-war</artifactId>      <version>1.2-SNAPSHOT</version>      <type>war</type>      <scope>runtime</scope>    </dependency>  </dependencies></project>
Currently only snapshot releases have been deployed to the repository (1.2-SNAPSHOT). Once we have some feedback that this is working OK, I will deploy a retrospective dojo 1.1.1 release and organize for that to be mirrored to the central maven repositories.   Until that time, 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>
I am now using these artifacts to better mavenize the cometd project and it’s examples. Feedback on the repositories and the packaging is most welcome.

10 Comments

Carlos Sanchez · 10/07/2008 at 18:27

Nice, I was looking into this too and didn’t know you were a dojo committer 😉 i uploaded the last zip releases to central.
is there rsync over ssh available at the server to sync the releases to maven central?

Greg Wilkins · 10/07/2008 at 22:12

Hey Carlos,
The machine is definitely capable, but I’ll have to check with the dojo infrastructure guys if it is permissible to setup an rsync account.

cheers

Brett Porter · 11/07/2008 at 05:34

cool, I was looking for this last year 🙂

Greg Wilkins · 11/07/2008 at 09:24

Since published, the group/artifact ID for the war has changes from org.dojotoolkit.java/dojo to org.dojotoolkit/dojo-war

Lars Trieloff · 12/07/2008 at 14:08

Cool, this will ease the build process for Apache Sling a bit. Currently we are pulling the ZIP files via Ant and verify the MD5 sum, but being able to use Maven is much easier. Thank you very much.

Brian DUpras · 13/07/2008 at 02:59

Thanks for the great work – I’m using the war overlay of dojo, and it appears to work as advertised.

Mikael FS · 06/08/2008 at 15:05

Hi Greg,
Thank you for the great work.
I have a question which is slightly different from the topic in this post.
In Jetty 6.1.9, I find out that the bayeux load generator and org.mortbay.jetty.client are not included in the package. i’m now performing some tests with jetty and bayeux and will be very glad if i can find the missing files.

Athena · 11/08/2008 at 03:36

Mikael,

Don’t know if you’ve found it yet, but the cometd package is available here:

http://svn.codehaus.org/jetty-contrib/branches/jetty-6.1.x/contrib/

That should also be available in the jetty6 distribution zip, or  pulled in automatically (as an external module) if you did an svn checkout of http://svn.codehaus.org/jetty/jetty/branches/jetty-6.1/.

Joel · 19/12/2008 at 20:06

Thanks for making Dojo available via a Maven repo!
It looks like the latest release available in the repo is 1.2.0, while the latest official Dojo release is 1.2.3. Is it possible a cron job that copies releases over to the repo broke?

Lars Schlanbusch · 13/07/2010 at 01:36

Hi,
I cannot find the maven folder in dojo/util after checking out dojo with: svn co http://svn.dojotoolkit.org/src/view/anon/all/trunk dojo
Did a search for “maven” in the download folder, and did not find anything. Is it me that is blind? 🙂
Kindly regards,
Lars Schlanbusch

Comments are closed.