My favorites | Sign in
Project Logo
                
Search
for
Updated May 24, 2008 by dhanji
WarpWithMaven2  
Building Warp-persist with Maven2

Building with mvn

This guide is copied verbatim from an email to the warp mailing list. Thanks to dani for the effort.

because i use maven to all my infrastructure i added some pom.xml to warp-core and warp-persist discalimer: this is all a little tricky and need some manual work. mvn usage is assumed... but you can ask me for an help...

what i did:

Part A: build and install warp-core in your own maven repo

  1. download warp-core sources (using svn)
  2. add the pom.xml to the warp-core root folder (the pom.xml is listed below)
  3. mvn install
  4. probably you will have to install some dependencies by hand (i.e: guice... maven will tell you how... but you have to download this dependecies before!)
  5. mvn install until it build with no errors (the test are not running... if you have some problems with the test you could aso do mvn install -Dtest=false)

Part B: build and install warp-persist in your own maven repo

  1. download warp-persist sources (using svn)
  2. add the pom.xml to the warp-persist root folder (listed below, also)
  3. mvn install
  4. install by hand the requiered dependecies not founded in the mvn main repo
  5. mvn install unit it build with no errors (the same with the tests!)

Part C: create your own project

  1. create a project folder
  2. drop the example pom.xml (listed below also)
  3. mvn eclipse:eclipse or mvn idea:idea to create the project for your favourite ide
  4. mvn jetty:run to un the project inside jetty

... you can create your own project using an archetype (recommended!!) and then adding the requiered dependencies (in the example i'm using commons-lang auto generate the toString, equals and hashCode in the models, and the mysql-connector as jdbc driver) web.xml and persistence.xml is also required (an example of both at the end of this msg)

POM.XML FOR WARP-CORE

<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>com.wideplay</groupId>
       <artifactId>warp-core</artifactId>
       <packaging>jar</packaging>
       <version>1.0-SNAPSHOT</version>
       <name>warp-core</name>
       <url>http://maven.apache.org</url>
       <dependencies>
               <dependency>
                       <groupId>ognl</groupId>
                       <artifactId>ognl</artifactId>
                       <version>2.6.7</version>
               </dependency>
               <dependency>
                       <groupId>commons-io</groupId>
                       <artifactId>commons-io</artifactId>
                       <version>1.3</version>
               </dependency>
               <dependency>
                       <groupId>commons-logging</groupId>
                       <artifactId>commons-logging</artifactId>
                       <version>1.0.4</version>
               </dependency>
               <dependency>
                       <groupId>dom4j</groupId>
                       <artifactId>dom4j</artifactId>
                       <version>1.6.1</version>
               </dependency>
               <dependency>
                       <groupId>jaxen</groupId>
                       <artifactId>jaxen</artifactId>
                       <version>1.1-beta-7</version>
               </dependency>
               <dependency>
                       <groupId>log4j</groupId>
                       <artifactId>log4j</artifactId>
                       <version>1.2.14</version>
               </dependency>
               <dependency>
                       <groupId>oro</groupId>
                       <artifactId>oro</artifactId>
                       <version>2.0.8</version>
               </dependency>

               <dependency>
                       <groupId>javax.servlet</groupId>
                       <artifactId>servlet-api</artifactId>
                       <version>2.4</version>
                       <scope>provided</scope>
               </dependency>
               <dependency>
                       <groupId>com.google.code.guice</groupId>
                       <artifactId>guice</artifactId>
                       <version>1.0</version>
               </dependency>
               <dependency>
                       <groupId>com.google.code.guice</groupId>
                       <artifactId>guice-servlet</artifactId>
                       <version>1.0</version>
               </dependency>
               <dependency>
                       <groupId>aopalliance</groupId>
                       <artifactId>aopalliance</artifactId>
                       <version>1.0</version>
               </dependency>


               <!-- TEST -->
               <dependency>
                       <groupId>org.testng</groupId>
                       <artifactId>testng</artifactId>
                       <version>5.1</version>
                       <classifier>jdk15</classifier>
                       <scope>test</scope>
               </dependency>
       </dependencies>
       <build>
               <sourceDirectory>${basedir}/src</sourceDirectory>
               <testSourceDirectory>${basedir}/test</testSourceDirectory>
               <finalName>warp-core</finalName>
               <plugins>
                       <plugin>
                               <groupId>org.apache.maven.plugins</groupId>
                               <artifactId>maven-compiler-plugin</artifactId>
                               <configuration>
                                       <source>1.5</source>
                                       <target>1.5</target>
                               </configuration>
                       </plugin>

                       <plugin>
                               <artifactId>maven-surefire-plugin</artifactId>
                       </plugin>

                       <plugin>
                               <artifactId>maven-eclipse-plugin</artifactId>
                               <version>2.3</version>
                               <configuration>
                                       <downloadSources>true</downloadSources>
                                       <downloadJavadocs>true</downloadJavadocs>
                               </configuration>
                       </plugin>
               </plugins>
       </build>
</project>

POM.XML FOR WARP-PERSIST

<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>com.wideplay</groupId>
       <artifactId>warp-persist</artifactId>
       <packaging>jar</packaging>
       <version>1.0-SNAPSHOT</version>
       <name>warp-persist</name>
       <url>http://maven.apache.org</url>
       <dependencies>

               <dependency>
                       <groupId>com.wideplay</groupId>
                       <artifactId>warp-core</artifactId>
                       <version>1.0-SNAPSHOT</version>
               </dependency>

               <dependency>
                       <groupId>javax.servlet</groupId>
                       <artifactId>servlet-api</artifactId>
                       <version>2.4</version>
                       <scope>provided</scope>
               </dependency>
               <dependency>
                       <groupId>com.google.code.guice</groupId>
                       <artifactId>guice</artifactId>
                       <version>1.0</version>
               </dependency>
               <dependency>
                       <groupId>com.google.code.guice</groupId>
                       <artifactId>guice-servlet</artifactId>
                       <version>1.0</version>
               </dependency>
               <dependency>
                       <groupId>aopalliance</groupId>
                       <artifactId>aopalliance</artifactId>
                       <version>1.0</version>
               </dependency>

       <!-- hibernate + jpa -->
       <dependency>
           <groupId>org.hibernate</groupId>
           <artifactId>hibernate</artifactId>
           <version>3.2.2.ga</version>
       </dependency>
       <dependency>
           <groupId>org.hibernate</groupId>
           <artifactId>hibernate-annotations</artifactId>
           <version>3.2.1.ga</version>
       </dependency>
       <dependency>
           <groupId>org.hibernate</groupId>
           <artifactId>hibernate-entitymanager</artifactId>
           <version>3.2.1.ga</version>
       </dependency>
       <dependency>
           <groupId>org.hibernate</groupId>
           <artifactId>hibernate-tools</artifactId>
           <version>3.2.0.beta9a</version>
       </dependency>
       <dependency>
           <groupId>c3p0</groupId>
           <artifactId>c3p0</artifactId>
           <version>0.9.1.1</version>
       </dependency>


               <!-- TEST -->
               <dependency>
                       <groupId>org.testng</groupId>
                       <artifactId>testng</artifactId>
                       <version>5.1</version>
                       <classifier>jdk15</classifier>
                       <scope>test</scope>
               </dependency>
       </dependencies>
       <build>
               <sourceDirectory>${basedir}/src</sourceDirectory>
               <testSourceDirectory>${basedir}/test</testSourceDirectory>
               <finalName>warp-persist</finalName>
               <plugins>
                       <plugin>
                               <groupId>org.apache.maven.plugins</groupId>
                               <artifactId>maven-compiler-plugin</artifactId>
                               <configuration>
                                       <source>1.5</source>
                                       <target>1.5</target>
                               </configuration>
                       </plugin>

                       <plugin>
                               <artifactId>maven-eclipse-plugin</artifactId>
                               <version>2.3</version>
                               <configuration>
                                       <downloadSources>true</downloadSources>
                                       <downloadJavadocs>true</downloadJavadocs>
                                       <wtpversion>1.5</wtpversion>
                               </configuration>
                       </plugin>
               </plugins>
       </build>
</project>

POM.XML EXAMPLE FOR A NEW PROJECT USING BOTH LIBS

<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>your.domain.here</groupId>
       <artifactId>AppName</artifactId>
       <packaging>war</packaging>
       <version>1.0-SNAPSHOT</version>
       <name>apy Maven Webapp</name>
       <url>http://maven.apache.org</url>
       <dependencies>
               <dependency>
                       <groupId>com.wideplay</groupId>
                       <artifactId>warp-core</artifactId>
                       <version>1.0-SNAPSHOT</version>
               </dependency>
               <dependency>
                       <groupId>com.wideplay</groupId>
                       <artifactId>warp-persist</artifactId>
                       <version>1.0-SNAPSHOT</version>
               </dependency>
               <dependency>
                       <groupId>mysql</groupId>
                       <artifactId>mysql-connector-java</artifactId>
                       <version>5.0.5</version>
               </dependency>
               <dependency>
                       <groupId>commons-lang</groupId>
                       <artifactId>commons-lang</artifactId>
                       <version>2.3</version>
               </dependency>

               <dependency>
                       <groupId>junit</groupId>
                       <artifactId>junit</artifactId>
                       <version>4.3.1</version>
                       <scope>test</scope>
               </dependency>
       </dependencies>
       <build>
               <finalName>AppName</finalName>
               <plugins>
                       <plugin>
                               <groupId>org.apache.maven.plugins</groupId>
                               <artifactId>maven-compiler-plugin</artifactId>
                               <configuration>
                                       <source>1.5</source>
                                       <target>1.5</target>
                               </configuration>
                       </plugin>

                       <plugin>
                               <artifactId>maven-eclipse-plugin</artifactId>
                               <version>2.3</version>
                               <configuration>
                                       <additionalProjectnatures>
                                               <projectnature>
                                                       org.springframework.ide.eclipse.core.springnature
                                               </projectnature>
                                       </additionalProjectnatures>
                                       <additionalBuildcommands>
                                               <buildcommand>
                                                       org.springframework.ide.eclipse.core.springbuilder
                                               </buildcommand>
                                       </additionalBuildcommands>
                                       <downloadSources>true</downloadSources>
                                       <downloadJavadocs>true</downloadJavadocs>
                                       <wtpversion>1.5</wtpversion>
                               </configuration>
                       </plugin>

                       <plugin>
                               <groupId>org.mortbay.jetty</groupId>
                               <artifactId>maven-jetty-plugin</artifactId>
                               <version>6.1.3</version>
                               <configuration>
                                       <contextPath>/AppName</contextPath>
                                       <scanIntervalSeconds>1</scanIntervalSeconds>
                               </configuration>
                       </plugin>
               </plugins>
       </build>
</project>

PERSISTENCE.XML EXAMPLE

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
  http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
  version="1.0">

 <persistence-unit name="development" transaction-
type="RESOURCE_LOCAL">
   <provider>org.hibernate.ejb.HibernatePersistence</provider>
   <properties>
     <property name="hibernate.archive.autodetection" value="class,
hbm"/>
     <property name="hibernate.show_sql" value="true"/>
     <property name="hibernate.format_sql" value="true"/>
     <property name="use_sql_comments" value="true"/>
     <property name="hibernate.dialect"
value="org.hibernate.dialect.MySQLDialect"/>
     <property name="hibernate.connection.driver_class"
value="com.mysql.jdbc.Driver"/>
     <property name="hibernate.connection.url" value="jdbc:mysql://
localhost/dbname?
createDatabaseIfNotExist=true&amp;useUnicode=true&amp;characterEncoding=utf-8"/
>
     <property name="hibernate.connection.username" value="name"/>
     <property name="hibernate.connection.password" value="password" /
>
     <property name="hibernate.hbm2ddl.auto" value="update"/>
     <property name="hibernate.c3p0.min_size" value="5"/>
     <property name="hibernate.c3p0.max_size" value="20"/>
     <property name="hibernate.c3p0.timeout" value="300"/>
     <property name="hibernate.c3p0.max_statements" value="50"/>
     <property name="hibernate.c3p0.idle_test_period" value="3000"/>
   </properties>
 </persistence-unit>

</persistence>

WEB.XML EXAMPLE

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
        xmlns="http://java.sun.com/xml/ns/j2ee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >

   <context-param>
       <param-name>warp.module</param-name>
       <param-value>com.calc.apy.pages.ApyModule</param-value>
   </context-param>

   <filter>
       <filter-name>warp</filter-name>
       <filter-class>com.wideplay.warp.WarpFilter</filter-class>
   </filter>

   <filter-mapping>
       <filter-name>warp</filter-name>
       <url-pattern>/*</url-pattern>
   </filter-mapping>

   <welcome-file-list>
       <welcome-file>/Welcome</welcome-file>
   </welcome-file-list>
</web-app>

Sign in to add a comment
Hosted by Google Code