<?xml version="1.0"?>
<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/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.terracotta.forge</groupId>
    <artifactId>forge-parent</artifactId>
    <version>2.3</version>
  </parent>
  
  <groupId>org.terracotta.samples.ehcache.hibernate</groupId>
  <artifactId>events</artifactId>
  <version>3.6.7-SNAPSHOT</version>
  <name>events</name>
  <packaging>war</packaging>
  <description>Clustered Ehcache Terracotta as second level cache for Hibernate</description>

  <properties>
    <tc-maven-plugin.version>1.8.7-SNAPSHOT</tc-maven-plugin.version>
    <ehcache-core.version>2.5.8-SNAPSHOT</ehcache-core.version>
    <ehcache-terracotta.version>2.5.8-SNAPSHOT</ehcache-terracotta.version>
    <h2.version>1.1.116</h2.version>
    <jetty.version>6.1.15</jetty.version>
    <exec-maven-plugin.version>1.1</exec-maven-plugin.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <version>3.3.1.GA</version>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>2.5</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.6.1</version>
    </dependency>
    
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>1.6.1</version>
    </dependency>

    <dependency>
      <groupId>javassist</groupId>
      <artifactId>javassist</artifactId>
      <version>3.8.0.GA</version>
    </dependency>

    <dependency>
      <artifactId>h2</artifactId>
      <version>${h2.version}</version>
      <groupId>com.h2database</groupId>
    </dependency>

    <dependency>
      <groupId>net.sf.ehcache</groupId>
      <artifactId>ehcache-core</artifactId>
      <version>${ehcache-core.version}</version>
    </dependency>      

    <dependency>
      <groupId>net.sf.ehcache</groupId>
      <artifactId>ehcache-terracotta</artifactId>
      <version>${ehcache-terracotta.version}</version>
    </dependency>      

    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.1</version>
      <scope>compile</scope>
      <exclusions>
        <exclusion>
          <groupId>log4j</groupId>
          <artifactId>log4j</artifactId>
        </exclusion>
        <exclusion>
          <groupId>logkit</groupId>
          <artifactId>logkit</artifactId>
        </exclusion>
        <exclusion>
          <groupId>avalon-framework</groupId>
          <artifactId>avalon-framework</artifactId>
        </exclusion>
        <exclusion>
          <groupId>javax.servlet</groupId>
          <artifactId>servlet-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>

  <build>
    <!-- we dont want the version to be part of the generated war file name -->
    <finalName>${project.name}</finalName>
    
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.2-beta-5</version>
        <configuration>
          <finalName>${project.name}</finalName>
          <descriptors>
            <descriptor>src/assemble/distribution.xml</descriptor>
          </descriptors>
          <tarLongFileMode>gnu</tarLongFileMode>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <groupId>org.apache.maven.plugins</groupId>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>

      <plugin>
        <artifactId>maven-jetty-plugin</artifactId>
        <version>${jetty.version}</version>
        <groupId>org.mortbay.jetty</groupId>
        <configuration>
          <contextPath>${name}</contextPath>
          <stopKey>STOP</stopKey>
        </configuration>
      </plugin>

      <plugin>
        <artifactId>hibernate3-maven-plugin</artifactId>
        <version>2.1</version>
        <groupId>org.codehaus.mojo</groupId>
        <configuration>
          <componentProperties>
            <propertyfile>target/classes/hibernate3hbm2ddl.properties</propertyfile>
            <configurationfile>target/classes/hibernate.cfg.xml</configurationfile>
            <drop>true</drop>
            <export>true</export>
           <outputfilename>schema.sql</outputfilename>
          </componentProperties>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>${h2.version}</version>
          </dependency>
        </dependencies>
      </plugin>

      <plugin>
        <groupId>org.terracotta.maven.plugins</groupId>
        <artifactId>tc-maven-plugin</artifactId>
        <version>${tc-maven-plugin.version}</version>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>start-h2</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>${exec-maven-plugin.version}</version>
            <configuration>
              <mainClass>org.h2.tools.Server</mainClass>
              <arguments>
                <argument>-tcp</argument>
                <argument>-tcpAllowOthers</argument>
              </arguments>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>stop-h2</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>${exec-maven-plugin.version}</version>
            <configuration>
              <mainClass>org.h2.tools.Server</mainClass>
              <arguments>
                <argument>-tcpShutdown</argument>
                <argument>tcp://localhost:9092</argument>
              </arguments>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>9081</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-jetty-plugin</artifactId>
            <version>${jetty.version}</version>
            <groupId>org.mortbay.jetty</groupId>
            <configuration>
              <systemProperties>
                <systemProperty>
                  <name>jetty.port</name>
                  <value>9081</value>
                </systemProperty>
              </systemProperties>
              <stopPort>9981</stopPort>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>9082</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-jetty-plugin</artifactId>
            <version>${jetty.version}</version>
            <groupId>org.mortbay.jetty</groupId>
            <configuration>
              <systemProperties>
                <systemProperty>
                  <name>jetty.port</name>
                  <value>9082</value>
                </systemProperty>
              </systemProperties>
              <stopPort>9982</stopPort>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
  
  <repositories>
    <repository>
      <id>terracotta-releases</id>
      <url>http://www.terracotta.org/download/reflector/releases</url>
      <releases><enabled>true</enabled></releases>
      <snapshots><enabled>false</enabled></snapshots>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>      
    <id>terracotta-releases</id>      
    <url>http://www.terracotta.org/download/reflector/releases</url>
      <releases><enabled>true</enabled></releases>
      <snapshots><enabled>false</enabled></snapshots>
    </pluginRepository>
  </pluginRepositories>  

</project>
