Building a Zimbra Server Extension using Maven

I’m currently working on a project for a customer involving several parts for Zimbra (well, whaddya know?) – one is a server extension. And I’d like to have the features, Maven brings in my workflow. The problem is, that Zimbra isn’t really made to be used in Maven. The components you need to create server extensions are built using Ant from the Zimbra sources.

However, it’s still possible – with some modifications.

First, get the Zimbra source code and compile at least these four modules:

  • ZimbraCommon
  • ZimbraSoap
  • ZimbraServer
  • ZimbraClient

All modules should compile by simply going into the corresponding directory and calling „ant“.

Afterwards, you’ll find these 4 jars in the subdirectory „build“ in each module:

  • zimbracommon.jar
  • zimbrasoap.jar
  • zimbrastore.jar
  • zimbraclient.jar

Before we can install these files into the local maven repository, we need to get the current version of the sources you’ve downloaded like this:

VERSION="`cat ZimbraBuild/RE/MAJOR`.`cat ZimbraBuild/RE/MINOR`.`cat ZimbraBuild/RE/MICRO`"

Finally call maven to install the files:

mvn install:install-file -Dfile=ZimbraCommon/build/zimbracommon.jar -DgroupId=com.zimbra -DartifactId=zimbrCommon -Dversion="$VERSION" -Dpackaging=jar

mvn install:install-file -Dfile=ZimbraSoap/build/zimbrasoap.jar -DgroupId=com.zimbra -DartifactId=zimbraSoap -Dversion="$VERSION" -Dpackaging=jar

mvn install:install-file -Dfile=ZimbraServer/build/zimbrastore.jar -DgroupId=com.zimbra -DartifactId=zimbraServer -Dversion="$VERSION" -Dpackaging=jar

mvn install:install-file -Dfile=ZimbraClient/build/zimbraclient.jar -DgroupId=com.zimbra -DartifactId=zimbraClient -Dversion="$VERSION" -Dpackaging=jar

Now we can use these files as dependencies in the maven pom.xml file:

<dependency>
    <groupId>com.zimbra</groupId>
    <artifactId>zimbraSoap</artifactId>
    <version>8.7.0_RC1</version>
</dependency>
<dependency>
    <groupId>com.zimbra</groupId>
    <artifactId>zimbraClient</artifactId>
    <version>8.7.0_RC1</version>
</dependency>
<dependency>
    <groupId>com.zimbra</groupId>
    <artifactId>zimbraServer</artifactId>
    <version>8.7.0_RC1</version>
</dependency>
<dependency>
    <groupId>com.zimbra</groupId>
    <artifactId>zimbraCommon</artifactId>
    <version>8.7.0_RC1</version>
</dependency>

(Use the version you’re developing with here, of course)

But let me give you a warning here: If you like to use further packages other than Zimbra itself (you surely will!), be sure to use the version, that comes with your version of Zimbra (see the jars subdirectory in the ZimbraServer module). If you need other, non-bundled packages, be sure to install them on your server.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.