<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>

  <parent>
    <groupId>com.redhat.rhevm.api</groupId>
    <artifactId>mock-parent</artifactId>
    <version>0.9-milestone3.3</version>
  </parent>

  <artifactId>rhevm-api-mock-webapp</artifactId>
  <packaging>war</packaging>

  <name>RHEV-M API Mock Implementation Webapp</name>
  <url>http://fedorahosted.org/rhevm-api/</url>

  <properties>
    <webapp.name>rhevm-api-mock</webapp.name>
    <keystore>${project.build.directory}/security/keystore</keystore>
    <key.password>Open_sesame</key.password>
    <keystore.password>Open_sesame</keystore.password>
  </properties>

  <profiles>
    <profile>
      <id>insecure</id>
      <properties>
        <maven.war.webxml>${basedir}/src/main/webapp/WEB-INF/web-insecure.xml</maven.war.webxml>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>maven-jetty-plugin</artifactId>
            <configuration>
              <contextPath>${webapp.name}</contextPath>
              <scanIntervalSeconds>10</scanIntervalSeconds>
              <connectors>
                <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                  <port>8099</port>
                  <maxIdleTime>60000</maxIdleTime>
                </connector>
              </connectors>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>secure</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>keytool-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>clean-keys</id>
                <phase>initialize</phase>
                <goals>
                  <goal>clean</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>keytool-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>generate-keys</id>
                <phase>generate-test-resources</phase>
                <goals>
                  <goal>genkey</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <keystore>${keystore}</keystore>
              <dname>cn=localhost, ou=rhevm-api, L=Dublin, ST=None, o=fedorahosted.org, c=IE</dname>
              <keypass>${key.password}</keypass>
              <storepass>${keystore.password}</storepass>
            </configuration>
          </plugin>

          <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>maven-jetty-plugin</artifactId>
            <configuration>
              <contextPath>${webapp.name}</contextPath>
              <scanIntervalSeconds>10</scanIntervalSeconds>
              <connectors>
                <connector implementation="org.mortbay.jetty.security.SslSocketConnector">
                  <port>8943</port>
                  <maxIdleTime>60000</maxIdleTime>
                  <keystore>${keystore}</keystore>
                  <password>${key.password}</password>
                  <keyPassword>${keystore.password}</keyPassword>
                </connector>
              </connectors>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <dependencies>

    <dependency>
      <groupId>com.redhat.rhevm.api</groupId>
      <artifactId>rhevm-api-mock-jaxrs</artifactId>
      <version>${project.version}</version>
    </dependency>

    <dependency>
      <groupId>com.redhat.rhevm.api</groupId>
      <artifactId>rhevm-api-common-jaxrs</artifactId>
      <version>${project.version}</version>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
    </dependency>

    <dependency>
      <groupId>org.jboss.resteasy</groupId>
      <artifactId>resteasy-jaxrs</artifactId>
    </dependency>

    <dependency>
      <groupId>org.jboss.resteasy</groupId>
      <artifactId>resteasy-spring</artifactId>
    </dependency>

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>httpunit</groupId>
      <artifactId>httpunit</artifactId>
      <scope>test</scope>
      <version>${httpunit.version}</version>
    </dependency>

    <!-- Spring dependencies are provided scope in resteasy-spring pom,
         hence they are not pulled in transitively -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
    </dependency>

  </dependencies>

  <build>
    <finalName>${webapp.name}</finalName>
  </build>

</project>
