<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.7.2</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>
    
    <!-- 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.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-modeshape</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-auth-common</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.fcrepo</groupId>
      <artifactId>jena-patch</artifactId>
      <version>${project.version}</version>
    </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>

    <!-- JDBC dependencies-->
    <dependency>
      <groupId>com.mchange</groupId>
      <artifactId>c3p0</artifactId>
    </dependency>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>${mysql.version}</version>
    </dependency>
    <dependency>
	  <groupId>org.postgresql</groupId>
	  <artifactId>postgresql</artifactId>
    <version>${postgresql.version}</version>
    </dependency>

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

    <!-- test gear -->
    <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-io</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>

    <dependency>
      <groupId>org.reflections</groupId>
      <artifactId>reflections</artifactId>
      <version>0.9.10</version>
      <scope>test</scope>
    </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>
        <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.eclipse.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <configuration>
          <scanIntervalSeconds>2</scanIntervalSeconds>
          <stopKey>STOP</stopKey>
          <webApp>
            <contextPath>${fcrepo.test.context.path}</contextPath>
          </webApp>
          <systemProperties>
            <systemProperty>
              <name>fcrepo.modeshape.configuration</name>
              <value>classpath:/config/file-simple/repository.json</value>
            </systemProperty>
          </systemProperties>

        </configuration>
        <executions>
          <execution>
            <id>start-jetty</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>stop</goal>
              <goal>start</goal>
            </goals>
            <configuration>
              <jettyXml>${project.basedir}/src/test/resources/jetty-test.xml</jettyXml>
              <stopPort>${jetty.dynamic.stop.port}</stopPort>

              <systemProperties>
                <systemProperty>
                  <name>fcrepo.modeshape.configuration</name>
                  <value>classpath:/config/file-simple/repository.json</value>
                </systemProperty>

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

                <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>one-click</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <properties>
        <fcrepo.modeshape.configuration>classpath:/config/file-simple/repository.json</fcrepo.modeshape.configuration>
      </properties>

      <build>
        <resources>
          <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
            <includes>
              <include>**/repo.xml</include>
            </includes>
          </resource>
        </resources>

        <plugins>
          <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/static/images/fedora_logo_10in.png</backgroundImage>
                  <destinationFile>
                    ${project.build.directory}${file.separator}${project.artifactId}-${project.version}-jetty-console.jar
                  </destinationFile>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <!--Ensure that the main war is removed... because it will have a default ModeShape config wired in.-->
          <plugin>
            <artifactId>maven-clean-plugin</artifactId>
            <executions>
              <execution>
                <id>remove-war</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>clean</goal>
                </goals>
                <configuration>
                  <excludeDefaultDirectories>true</excludeDefaultDirectories>
                  <filesets>
                    <fileset>
                      <directory>${project.build.directory}</directory>
                      <includes>
                        <include>**/*.war</include>
                      </includes>
                    </fileset>
                  </filesets>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
