Apache Cayenne > Index > Cayenne FAQ > Cayenne Maven
Added by Andrus Adamchik, last edited by Andrus Adamchik on Apr 06, 2006

Maven is a popular project management and build system. This page explains how to use Cayenne in projects that are built with Maven2.

Setting Up Cayenne as a Dependency

Cayenne releases are being posted to the Ibiblio Maven2 repository since version 1.2. So you can add Cayenne to your dependency list, as you would do for any other dependency:

<dependency>
   <groupId>org.objectstyle.cayenne</groupId>
   <artifactId>cayenne-nodeps</artifactId>
   <version>1.2M12</version>
</dependency>

Other available artifacts are cayenne that matches the contents of cayenne.jar (i.e. includes dependencies) and cayenne-client-nodeps that contains classes for Remote Object Persistence client.

Using Ant Tasks

Cayenne Ant Tasks, can be invoked from Maven using maven-antrun-plugin. E.g. cgen can be called during generate-sources phase:

pom.xml:

...
<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <executions>
    <execution>
      <phase>generate-sources</phase>
      <goals><goal>run</goal></goals>
      <configuration>
        <tasks>
          <ant target="generate-classes" inheritrefs="true"/>
       </tasks>
      </configuration>
   </execution>
</executions>
</plugin>

build.xml:

<project>
 <target name="generate-classes">
    <typedef resource="org/objectstyle/cayenne/tools/antlib.xml"
	classpathref="maven.compile.classpath"/>
		
    <cgen map="src/main/resources/sitedb.map.xml" destDir="src/main/java"
	superpkg="com.xyz.auto"/>
 </target>
</project>