<?xml version="1.0" encoding="UTF-8"?>
<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>sonia.scm</groupId>
    <artifactId>scm</artifactId>
    <version>1.46</version>
  </parent>

  <groupId>sonia.scm</groupId>
  <artifactId>scm-webapp</artifactId>
  <packaging>war</packaging>
  <version>1.46</version>
  <name>scm-webapp</name>

  <dependencies>

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>${servlet.version}</version>
      <scope>provided</scope>
    </dependency>

    <!-- fix javadoc -->
    
    <dependency>    
      <groupId>javax.transaction</groupId>
      <artifactId>jta</artifactId>
      <version>1.1</version>
      <scope>provided</scope>
    </dependency>
    
    <!-- scm -->
    
    <dependency>
      <groupId>sonia.scm</groupId>
      <artifactId>scm-core</artifactId>
      <version>1.46</version>
    </dependency>
    
    <dependency>
      <groupId>sonia.scm</groupId>
      <artifactId>scm-dao-xml</artifactId>
      <version>1.46</version>
    </dependency>

    <dependency>
      <groupId>sonia.scm.plugins</groupId>
      <artifactId>scm-hg-plugin</artifactId>
      <version>1.46</version>
    </dependency>

    <dependency>
      <groupId>sonia.scm.plugins</groupId>
      <artifactId>scm-svn-plugin</artifactId>
      <version>1.46</version>
    </dependency>

    <dependency>
      <groupId>sonia.scm.plugins</groupId>
      <artifactId>scm-git-plugin</artifactId>
      <version>1.46</version>
    </dependency>
    
    <!-- security -->

    <dependency>
      <groupId>org.apache.shiro</groupId>
      <artifactId>shiro-web</artifactId>
      <version>${shiro.version}</version>
    </dependency>
            
    <dependency>
      <groupId>org.apache.shiro</groupId>
      <artifactId>shiro-guice</artifactId>
      <version>${shiro.version}</version>
    </dependency>

    <!-- rest api -->

    <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-server</artifactId>
      <version>${jersey.version}</version>
    </dependency>

    <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-json</artifactId>
      <version>${jersey.version}</version>
      <exclusions>
        <exclusion>
          <artifactId>stax-api</artifactId>
          <groupId>stax</groupId>
        </exclusion>
        <exclusion>
          <artifactId>jaxb-impl</artifactId>
          <groupId>com.sun.xml.bind</groupId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-bundle</artifactId>
      <version>${jersey.version}</version>
    </dependency>

    <dependency>
      <groupId>com.sun.jersey.contribs</groupId>
      <artifactId>jersey-guice</artifactId>
      <version>${jersey.version}</version>
      <!-- included by dependency rewrite -->
      <scope>provided</scope>
    </dependency>
    
    <dependency>
      <groupId>com.sun.jersey.contribs</groupId>
      <artifactId>jersey-multipart</artifactId>
      <version>${jersey.version}</version>
    </dependency>
    
    <!-- injection -->

    <dependency>
      <groupId>com.google.inject.extensions</groupId>
      <artifactId>guice-multibindings</artifactId>
      <version>${guice.version}</version>
    </dependency>
    
    <!-- logging -->

    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>${logback.version}</version>
    </dependency>
    
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jcl-over-slf4j</artifactId>
      <version>${slf4j.version}</version>
    </dependency>
    
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>log4j-over-slf4j</artifactId>
      <version>${slf4j.version}</version>
    </dependency>
    
    <!-- cache -->

    <dependency>
      <groupId>net.sf.ehcache</groupId>
      <artifactId>ehcache-core</artifactId>
      <version>${ehcache.version}</version>
    </dependency>
    
    <!-- only for BeanComparator, replace with own implementation -->
    
    <dependency>
      <groupId>commons-beanutils</groupId>
      <artifactId>commons-beanutils</artifactId>
      <version>1.9.2</version>
    </dependency>
    
    <dependency>
      <groupId>commons-collections</groupId>
      <artifactId>commons-collections</artifactId>
      <version>3.2.1</version>
    </dependency>
    
    <!-- 
      fix installation of httpasswd-plugin 
      https://groups.google.com/d/topic/scmmanager/eN7UtG8TwW8/discussion
    -->
    
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <version>1.9</version>
    </dependency>
   
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>${guava.version}</version>
    </dependency>
    
    <!-- fix version conflict -->
    
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
      <version>4.2.6</version>
    </dependency>
    
    <!-- template engine -->

    <dependency>
      <groupId>org.freemarker</groupId>
      <artifactId>freemarker</artifactId>
      <version>${freemarker.version}</version>
    </dependency>
    
    <dependency>
      <groupId>com.github.spullara.mustache.java</groupId>
      <artifactId>compiler</artifactId>
      <version>${mustache.version}</version>
    </dependency>

    <!-- aether -->

    <dependency>
      <groupId>org.sonatype.aether</groupId>
      <artifactId>aether-api</artifactId>
      <version>${aether.version}</version>
    </dependency>

    <dependency>
      <groupId>org.sonatype.aether</groupId>
      <artifactId>aether-impl</artifactId>
      <version>${aether.version}</version>
    </dependency>

    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-aether-provider</artifactId>
      <version>${maven.version}</version>
      <exclusions>
        <exclusion>
          <artifactId>plexus-component-annotations</artifactId>
          <groupId>org.codehaus.plexus</groupId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.sonatype.aether</groupId>
      <artifactId>aether-connector-asynchttpclient</artifactId>
      <version>${aether.version}</version>
    </dependency>
    
    <dependency>
      <groupId>org.sonatype.aether</groupId>
      <artifactId>aether-connector-file</artifactId>
      <version>${aether.version}</version>
    </dependency>
    
    <!-- rest documentation -->
    
    <dependency>
      <groupId>org.codehaus.enunciate</groupId>
      <artifactId>enunciate-jersey-rt</artifactId>
      <version>${enunciate.version}</version>
      <!-- fix conflict with jersey-json -->
      <exclusions>
        <exclusion>
          <artifactId>jackson-jaxrs</artifactId>
          <groupId>org.codehaus.jackson</groupId>
        </exclusion>
        <exclusion>
          <artifactId>jackson-xc</artifactId>
          <groupId>org.codehaus.jackson</groupId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- test scope -->

    <dependency>
      <groupId>sonia.scm</groupId>
      <artifactId>scm-test</artifactId>
      <version>1.46</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-simple</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    
    <dependency>
      <groupId>sonia.scm.plugins</groupId>
      <artifactId>scm-git-plugin</artifactId>
      <version>1.46</version>
      <classifier>tests</classifier>
      <scope>test</scope>
    </dependency>
    
    <dependency>
      <groupId>sonia.scm.plugins</groupId>
      <artifactId>scm-hg-plugin</artifactId>
      <version>1.46</version>
      <classifier>tests</classifier>
      <scope>test</scope>
    </dependency>
    
    <dependency>
      <groupId>sonia.scm.plugins</groupId>
      <artifactId>scm-svn-plugin</artifactId>
      <version>1.46</version>
      <classifier>tests</classifier>
      <scope>test</scope>
    </dependency>
    
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <version>${selenium.version}</version>
      <scope>test</scope>
    </dependency>
    
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-firefox-driver</artifactId>
      <version>${selenium.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-client</artifactId>
      <version>${jersey.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.sun.jersey.contribs</groupId>
      <artifactId>jersey-apache-client</artifactId>
      <version>${jersey.version}</version>
      <scope>test</scope>
    </dependency>
    
    <!-- global excludes -->
    
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.1.3</version>
      <scope>provided</scope>
    </dependency>
    
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.17</version>
      <scope>provided</scope>
    </dependency>

  </dependencies>

  <build>

    <plugins>
    
      <plugin>
        <groupId>com.mycila.maven-license-plugin</groupId>
        <artifactId>maven-license-plugin</artifactId>
        <version>1.9.0</version>
        <configuration>
          <header>http://download.scm-manager.org/licenses/mvn-license.txt</header>
          <includes>
            <include>src/**</include>
            <include>**/test/**</include>
          </includes>
          <excludes>
            <exclude>target/**</exclude>
            <exclude>.hg/**</exclude>
            <exclude>src/main/webapp/resources/extjs/**</exclude>
            <exclude>src/main/webapp/resources/syntaxhighlighter/**</exclude>
            <exclude>src/main/webapp/resources/moment/**</exclude>
            <exclude>**/*.mustache</exclude>
          </excludes>
          <strictCheck>true</strictCheck>
        </configuration>
      </plugin>
      

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.4</version>
        <executions>
          <execution>
            <phase>compile</phase>
            <goals>
              <goal>list</goal>
            </goals>
            <configuration>
              <includeScope>runtime</includeScope>
              <outputFile>${project.build.directory}/classes/config/dependencies.list</outputFile>
            </configuration>
          </execution>
        </executions>
      </plugin>
      
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.6</version>
        <executions>
          <execution>
            <id>repack</id>
            <phase>compile</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <!--
                add beans.xml to jersey-guice
                -->
                <property name="beans.file" value="src/main/webapp/WEB-INF/beans.xml" />
                <property name="temp.dir" value="${project.build.directory}/tmp" />
                <property name="rewrite.dir" value="${project.build.directory}/dependency-rewrite/WEB-INF/lib" />
                <property name="suffix" value="gfcdifix" />

                <!-- jersey guice -->
                <property name="jersey.tmp" value="${temp.dir}/jersey-guice" />
                <unzip src="${com.sun.jersey.contribs:jersey-guice:jar}" dest="${jersey.tmp}" />
                <copy file="${beans.file}" toDir="${jersey.tmp}/META-INF" />
                <zip basedir="${jersey.tmp}" destfile="${rewrite.dir}/jersey-guice-${jersey.version}-${suffix}.jar" />
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>
      
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.2</version>
        <configuration>
          <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
          <webResources>
            <resource>
              <directory>${project.build.directory}/dependency-rewrite</directory>
            </resource>
          </webResources>
        </configuration>
      </plugin>

      <plugin>
        <groupId>sonia.maven</groupId>
        <artifactId>change-env</artifactId>
        <version>1.0</version>
        <configuration>
          <environment>${environment.profile}</environment>
          <pattern>.*(\.{env})\.xml</pattern>
        </configuration>
        <executions>
          <execution>
            <phase>process-resources</phase>
            <goals>
              <goal>change-env</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>${jetty.version}</version>
        <configuration>
          <stopPort>8005</stopPort>
          <stopKey>STOP</stopKey>
          <systemProperties>
            <systemProperty>
              <name>scm.home</name>
              <value>${scm.home}</value>
            </systemProperty>
            <systemProperty>
              <name>scm.stage</name>
              <value>${scm.stage}</value>
            </systemProperty>
            <systemProperty>
              <name>java.awt.headless</name>
              <value>true</value>
            </systemProperty>
          </systemProperties>
          <connectors>
            <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
              <port>8081</port>
              <maxIdleTime>60000</maxIdleTime>
              <requestHeaderSize>16384</requestHeaderSize>
            </connector>
          </connectors>
          <webApp>
            <contextPath>/scm</contextPath>
          </webApp>
          <source>${project.build.javaLevel}</source>
          <target>${project.build.javaLevel}</target>
          <encoding>${project.build.sourceEncoding}</encoding>
          <scanIntervalSeconds>0</scanIntervalSeconds>
        </configuration>
      </plugin>        
      
    </plugins>

    <finalName>scm-webapp</finalName>
  </build>

  <properties>
    <scm.stage>DEVELOPMENT</scm.stage>
    <scm.home>target/scm-it</scm.home>
    <environment.profile>default</environment.profile>
    <selenium.version>2.28.0</selenium.version>
    <enunciate.version>1.30.1</enunciate.version>
    <aether.version>1.13.1</aether.version>
    <wagon.version>1.0</wagon.version>
    <maven.version>3.0.5</maven.version>
    <mustache.version>0.8.17</mustache.version>
    <netbeans.hint.deploy.server>Tomcat</netbeans.hint.deploy.server>
  </properties>

  <profiles>
    
    <profile>
      <id>cluster</id>
      
      <dependencies>
        
        <dependency>
          <groupId>sonia.scm</groupId>
          <artifactId>scm-dao-orientdb</artifactId>
          <version>1.46</version>
        </dependency>
        
      </dependencies>
    </profile>

    <profile>
      <id>release</id>

      <build>
        <plugins>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.2</version>
            <configuration>
              <webResources>
                <resource>
                  <directory>${project.build.directory}/web-compressor</directory>
                </resource>
                <resource>
                  <directory>${project.build.directory}/dependency-rewrite</directory>
                </resource>
              </webResources>
            </configuration>
          </plugin>

          <plugin>
            <groupId>sonia.maven</groupId>
            <artifactId>web-compressor</artifactId>
            <version>1.5</version>
            <executions>
              <execution>
                <phase>prepare-package</phase>
                <goals>
                  <goal>partial-compress-template</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <source>src/main/webapp/index.mustache</source>
              <target>${project.build.directory}/web-compressor/index.mustache</target>
            </configuration>
          </plugin>

        </plugins>
      </build>

      <properties>
        <environment.profile>release</environment.profile>
      </properties>
    </profile>

    <profile>
      <id>it</id>

      <build>
        <plugins>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.12</version>
            <configuration>
              <includes>
                <include>sonia/scm/it/*ITCase.java</include>
              </includes>
            </configuration>
            <executions>
              <execution>
                <id>integration-test</id>
                <goals>
                  <goal>integration-test</goal>
                </goals>
              </execution>
              <execution>
                <id>verify</id>
                <goals>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>${jetty.version}</version>
            <configuration>
              <stopPort>8085</stopPort>
              <stopKey>STOP</stopKey>
              <systemProperties>
                <systemProperty>
                  <name>scm.home</name>
                  <value>target/scm-it</value>
                </systemProperty>
              </systemProperties>
              <connectors>
                <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
                  <port>8081</port>
                  <maxIdleTime>60000</maxIdleTime>
                  <requestHeaderSize>16384</requestHeaderSize>
                </connector>
              </connectors>
              <source>${project.build.javaLevel}</source>
              <target>${project.build.javaLevel}</target>
              <encoding>${project.build.sourceEncoding}</encoding>
              <scanIntervalSeconds>0</scanIntervalSeconds>
              <daemon>true</daemon>
            </configuration>
            <executions>
              <execution>
                <id>start-jetty</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>deploy-war</goal>
                </goals>
              </execution>
              <execution>
                <id>stop-jetty</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>stop</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          
        </plugins>
      </build>

    </profile>
    
    <profile>
      <id>selenium</id>
          
      <build>
        <plugins>
          
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.12</version>
            <configuration>
              <includes>
                <include>sonia/scm/selenium/*ITCase.java</include>
              </includes>
            </configuration>
            <executions>
              <execution>
                <id>integration-test</id>
                <goals>
                  <goal>integration-test</goal>
                </goals>
              </execution>
              <execution>
                <id>verify</id>
                <goals>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          
          <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>${jetty.version}</version>
            <configuration>
              <stopPort>8086</stopPort>
              <stopKey>STOP</stopKey>
              <systemProperties>
                <systemProperty>
                  <name>scm.home</name>
                  <value>target/scm-it</value>
                </systemProperty>
              </systemProperties>
              <connectors>
                <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
                  <port>8082</port>
                  <maxIdleTime>60000</maxIdleTime>
                  <requestHeaderSize>16384</requestHeaderSize>
                </connector>
              </connectors>
              <source>${project.build.javaLevel}</source>
              <target>${project.build.javaLevel}</target>
              <encoding>${project.build.sourceEncoding}</encoding>
              <scanIntervalSeconds>0</scanIntervalSeconds>
              <daemon>true</daemon>
            </configuration>
            <executions>
              <execution>
                <id>start-jetty</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>deploy-war</goal>
                </goals>
              </execution>
              <execution>
                <id>stop-jetty</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>stop</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>selenium-maven-plugin</artifactId>
            <version>2.3</version>
            <executions>
              <execution>
                <id>start-selenium-server</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>start-server</goal>
                </goals>
                <configuration>
                  <background>true</background>
                </configuration>
              </execution>
              <execution>
                <id>stop-selenium-server</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>stop-server</goal>
                </goals>                
              </execution>
            </executions>
          </plugin>
          
        </plugins>
      </build>
      
    </profile>
    
    <profile>
      <id>doc</id>
      
      <build>
        <plugins>
          
          <plugin>
            <groupId>org.codehaus.enunciate</groupId>
            <artifactId>maven-enunciate-plugin</artifactId>
            <version>${enunciate.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>docs</goal>
                </goals>
                <phase>compile</phase>
              </execution>
            </executions>
            <configuration>
              <configFile>src/main/doc/enunciate.xml</configFile>
              <docsDir>${project.build.directory}/restdocs</docsDir>
            </configuration>
            <dependencies>
              <dependency>
                <groupId>org.codehaus.enunciate</groupId>
                <artifactId>enunciate-jersey</artifactId>
                <version>${enunciate.version}</version>
              </dependency>
            </dependencies>
          </plugin>
          
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.3</version>
            <configuration>
              <descriptors>
                <descriptor>src/main/doc/assembly.xml</descriptor>
              </descriptors>
            </configuration>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>single</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          
        </plugins>
      </build>
    </profile>

  </profiles>
  
</project>

