<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>org.fcrepo</groupId>
    <artifactId>fcrepo</artifactId>
    <version>4.2.0</version>
  </parent>

  <artifactId>fcrepo-webapp</artifactId>
  <name>Fedora Repository Deployable Web Application</name>
  <description>The Fedora web application</description>
  <packaging>war</packaging>

  <properties>
    <!-- integration test properties -->
    <fcrepo.test.context.path>/</fcrepo.test.context.path>
    
    <!-- jmeter -->
    <jmeter.loop_count>100</jmeter.loop_count>
    <jmeter.num_threads>10</jmeter.num_threads>
    <jmeter.exit.check.pause>2000</jmeter.exit.check.pause>
    <jmeter.fixtures.dir>${project.build.directory}${file.separator}jmeter${file.separator}fixtures</jmeter.fixtures.dir>
    <jmeter.log.dir>${project.build.directory}${file.separator}jmeter${file.separator}log</jmeter.log.dir>
  
    <!-- sonar -->
    <sonar.artifact.path>${project.build.directory}${file.separator}${project.artifactId}-${project.version}.war</sonar.artifact.path>

    <build.timestamp>${maven.build.timestamp}</build.timestamp>
    <maven.build.timestamp.format>yyyy-MM-dd</maven.build.timestamp.format>
    <!-- for standalone operation -->
    <jetty.version>8.1.13.v20130916</jetty.version>
    <jetty.users.file>${project.build.directory}/test-classes/jetty-users.properties</jetty.users.file>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.fcrepo</groupId>
        <artifactId>fcrepo-jcr-bom</artifactId>
        <version>${project.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
    </dependency>
    <dependency>
      <groupId>org.fcrepo</groupId>
      <artifactId>fcrepo-kernel-impl</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.fcrepo</groupId>
      <artifactId>fcrepo-jms</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.fcrepo</groupId>
      <artifactId>fcrepo-http-api</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.fcrepo</groupId>
      <artifactId>fcrepo-configs</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.fcrepo</groupId>
      <artifactId>fcrepo-transform</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.fcrepo</groupId>
      <artifactId>fcrepo-auth-common</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.fcrepo</groupId>
      <artifactId>fcrepo-mint</artifactId>
      <version>${project.version}</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.fcrepo</groupId>
      <artifactId>fcrepo-connector-file</artifactId>
      <version>${project.version}</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-webapp</artifactId>
      <version>${jetty.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.eclipse.jetty.orbit</groupId>
          <artifactId>javax.servlet</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    
    <dependency>
      <groupId>io.dropwizard.metrics</groupId>
      <artifactId>metrics-core</artifactId>
      <version>${metrics.version}</version>
    </dependency>

    <dependency>
      <groupId>io.dropwizard.metrics</groupId>
      <artifactId>metrics-servlets</artifactId>
      <version>${metrics.version}</version>
    </dependency>

    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-servlets</artifactId>
      <version>${jetty.version}</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-deploy</artifactId>
      <version>${jetty.version}</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-jmx</artifactId>
      <version>${jetty.version}</version>
    </dependency>

    <dependency>
      <groupId>org.glassfish.jersey.ext</groupId>
      <artifactId>jersey-spring3</artifactId>
      <version>${jersey.version}</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
    </dependency>

    <dependency>
      <groupId>xml-apis</groupId>
      <artifactId>xml-apis</artifactId>
      <version>1.4.01</version>
    </dependency>

    <!-- test gear -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
    </dependency>
    <dependency>
      <groupId>org.infinispan</groupId>
      <artifactId>infinispan-cachestore-leveldb</artifactId>
    </dependency>
    <dependency>
      <groupId>net.sourceforge.htmlunit</groupId>
      <artifactId>htmlunit</artifactId>
      <scope>test</scope>
      <version>${htmlunit.version}</version>

      <exclusions>
        <exclusion>
          <groupId>commons-codec</groupId>
          <artifactId>commons-codec</artifactId>
        </exclusion>
        <exclusion>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.eclipse.jetty</groupId>
          <artifactId>jetty-http</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.eclipse.jetty</groupId>
          <artifactId>jetty-util</artifactId>
        </exclusion>
        <exclusion>
          <groupId>xml-apis</groupId>
          <artifactId>xml-apis</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>net.sourceforge.htmlunit</groupId>
      <artifactId>htmlunit-core-js</artifactId>
      <scope>test</scope>
      <version>${htmlunit.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient-cache</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpmime</artifactId>
    </dependency>
    <dependency>
      <groupId>org.fcrepo</groupId>
      <artifactId>fcrepo-http-commons</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
      <type>test-jar</type>
    </dependency>

    <!-- This dependency is for compile-time: it keeps this module independent
      of any given choice of JAX-RS implementation. It must be _after_ the test
      gear. Otherwise it will get loaded during test phase, but because this is
      just an API, the tests will not be able to execute. -->
    <dependency>
      <groupId>javax</groupId>
      <artifactId>javaee-api</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>javax.jcr</groupId>
      <artifactId>jcr</artifactId>
      <scope>compile</scope>
    </dependency>

    <dependency>
      <groupId>org.modeshape</groupId>
      <artifactId>modeshape-jcr</artifactId>
      <scope>runtime</scope>
    </dependency>
    
  </dependencies>
  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
      <resource>
        <directory>${project.build.directory}/maven-shared-archive-resources</directory>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <artifactId>maven-remote-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>process-remote-resources</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>process</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <resourceBundles>
            <resourceBundle>org.fcrepo:fcrepo-configs:${project.version}</resourceBundle>
          </resourceBundles>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <attachClasses>true</attachClasses>
          <webResources>
            <resource>
              <directory>src/main/webapp</directory>
              <filtering>true</filtering>
              <includes>
                <include>index.html</include>
              </includes>
            </resource>
          </webResources>
            <archive>
              <index>true</index>
              <manifest>
                <addClasspath>true</addClasspath>
                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
              </manifest>
            </archive>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.simplericity.jettyconsole</groupId>
        <artifactId>jetty-console-maven-plugin</artifactId>
        <version>1.56</version>
        <executions>
          <execution>
            <goals>
              <goal>createconsole</goal>
            </goals>
            <configuration>
              <backgroundImage>${basedir}/src/main/webapp/images/fedora_logo_10in.png</backgroundImage>
              <destinationFile>${project.build.directory}${file.separator}${project.artifactId}-${project.version}-jetty-console.jar</destinationFile>
            </configuration>
          </execution>
        </executions>
      </plugin>
        <plugin>
        <artifactId>maven-failsafe-plugin</artifactId>
        <configuration>
          <systemPropertyVariables>
            <fcrepo.dynamic.test.port>${fcrepo.dynamic.test.port}</fcrepo.dynamic.test.port>
            <fcrepo.test.context.path>${fcrepo.test.context.path}</fcrepo.test.context.path>
            <fcrepo.dynamic.jms.port>${fcrepo.dynamic.jms.port}</fcrepo.dynamic.jms.port>
            <fcrepo.dynamic.stomp.port>${fcrepo.dynamic.stomp.port}</fcrepo.dynamic.stomp.port>
            <integration-test>true</integration-test>
          </systemPropertyVariables>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <configuration>
          <portNames>
            <portName>fcrepo.dynamic.test.port</portName>
            <!-- reserves the stop port for jetty-maven-plugin -->
            <portName>jetty.dynamic.stop.port</portName>
            <portName>fcrepo.dynamic.jms.port</portName>
            <portName>fcrepo.dynamic.stomp.port</portName>
          </portNames>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>properties-maven-plugin</artifactId>
        <version>1.0-alpha-2</version>
        <executions>
          <execution>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>set-system-properties</goal>
            </goals>
            <configuration>
              <properties>
                <property>
                  <name>fcrepo.dynamic.jms.port</name>
                  <value>${fcrepo.dynamic.jms.port}</value>
                </property>

                <property>
                  <name>fcrepo.dynamic.stomp.port</name>
                  <value>${fcrepo.dynamic.stomp.port}</value>
                </property>

                <property>
                  <name>integration-test</name>
                  <value>true</value>
                </property>
              </properties>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <configuration>
          <loginServices>
            <loginService implementation="org.eclipse.jetty.security.HashLoginService">
              <name>fcrepo</name>
              <config>${jetty.users.file}</config>
            </loginService>
          </loginServices>
          <scanIntervalSeconds>2</scanIntervalSeconds>
          <stopKey>STOP</stopKey>
          <webApp>
            <contextPath>${fcrepo.test.context.path}</contextPath>
          </webApp>

        </configuration>
        <executions>
          <execution>
            <id>start-jetty</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>stop</goal>
              <goal>start</goal>
            </goals>
            <configuration>
              <connectors>
                <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
                  <port>${fcrepo.dynamic.test.port}</port>
                  <maxIdleTime>60000</maxIdleTime>
                </connector>
              </connectors>
              <daemon>true</daemon>
              <stopPort>${jetty.dynamic.stop.port}</stopPort>

              <systemProperties>
                <systemProperty>
                  <name>fcrepo.dynamic.jms.port</name>
                  <value>${fcrepo.dynamic.jms.port}</value>
                </systemProperty>

                <systemProperty>
                  <name>fcrepo.dynamic.stomp.port</name>
                  <value>${fcrepo.dynamic.stomp.port}</value>
                </systemProperty>

                <systemProperty>
                  <name>integration-test</name>
                  <value>true</value>
                </systemProperty>

                <systemProperty>
                  <name>
                    com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean.default.objectStoreDir
                  </name>
                  <value>${project.build.directory}/object-store-default</value>
                </systemProperty>

                <systemProperty>
                  <name>com.arjuna.ats.arjuna.objectstore.objectStoreDir</name>
                  <value>${project.build.directory}/object-store</value>
                </systemProperty>

                <systemProperty>
                  <name>fcrepo.activemq.directory</name>
                  <value>${project.build.directory}/active-mq</value>
                </systemProperty>
              </systemProperties>

            </configuration>
          </execution>
          <execution>
            <id>stop-jetty</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>stop</goal>
            </goals>
            <configuration>
              <stopPort>${jetty.dynamic.stop.port}</stopPort>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>buildnumber-maven-plugin</artifactId>
        <version>1.3</version>
        <executions>
          <execution>
            <phase>validate</phase>
            <goals>
              <goal>create</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <doCheck>false</doCheck>
          <doUpdate>false</doUpdate>
          <getRevisionOnlyOnce>true</getRevisionOnlyOnce>
          <shortRevisionLength>8</shortRevisionLength>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>jmeter</id>
      <build>
        <plugins>
          <plugin>
            <groupId>com.lazerycode.jmeter</groupId>
            <artifactId>jmeter-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>jmeter-tests</id>
                <phase>integration-test</phase>
                <goals>
                  <goal>jmeter</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <propertiesJMeter>
                <!-- Extend the period (in ms) JMeter waits for threads to close -->
                <!-- See: https://github.com/Ronnie76er/jmeter-maven-plugin/issues/56 -->
                <jmeter.exit.check.pause>${jmeter.exit.check.pause}</jmeter.exit.check.pause>
              </propertiesJMeter>
              <propertiesUser>
                <fedora_4_port>${fcrepo.dynamic.test.port}</fedora_4_port>
                <fedora_4_context>rest</fedora_4_context>
                <loop_count>${jmeter.loop_count}</loop_count>
                <num_threads>${jmeter.num_threads}</num_threads>
                <fixtures>${jmeter.fixtures.dir}</fixtures>
                <log>${jmeter.log.dir}</log>
              </propertiesUser>
              <resultsFileNameDateFormat>'jmeter'</resultsFileNameDateFormat>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
