<?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>
    <artifactId>scm-clients</artifactId>
    <groupId>sonia.scm.clients</groupId>
    <version>1.57</version>
  </parent>

  <groupId>sonia.scm.clients</groupId>
  <artifactId>scm-cli-client</artifactId>
  <version>1.57</version>
  <name>scm-cli-client</name>

  <dependencies>

    <!-- fix javadoc -->

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

    <dependency>
      <groupId>javax.transaction</groupId>
      <artifactId>jta</artifactId>
      <version>1.1</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>sonia.scm.clients</groupId>
      <artifactId>scm-client-impl</artifactId>
      <version>1.57</version>
    </dependency>

    <dependency>
      <groupId>args4j</groupId>
      <artifactId>args4j</artifactId>
      <version>2.0.29</version>
    </dependency>

    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>${logback.version}</version>
    </dependency>

    <dependency>
      <groupId>org.freemarker</groupId>
      <artifactId>freemarker</artifactId>
      <version>${freemarker.version}</version>
    </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>**/*.ftl</exclude>
          </excludes>
          <strictCheck>true</strictCheck>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.3</version>
        <configuration>
          <archive>
            <manifest>
              <mainClass>sonia.scm.cli.App</mainClass>
            </manifest>
          </archive>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

    </plugins>
  </build>

  <profiles>
    <profile>

      <id>it</id>

      <build>
        <plugins>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.4</version>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>copy</goal>
                </goals>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>sonia.scm</groupId>
                      <artifactId>scm-webapp</artifactId>
                      <version>${project.version}</version>
                      <type>war</type>
                      <outputDirectory>${project.build.directory}/webapp</outputDirectory>
                      <destFileName>scm-webapp.war</destFileName>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.12</version>
            <configuration>
              <systemPropertyVariables>
                <scm.version>${project.version}</scm.version>
              </systemPropertyVariables>
            </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.maven.version}</version>
            <configuration>
              <stopPort>8085</stopPort>
              <stopKey>STOP</stopKey>
              <systemProperties>
                <systemProperty>
                  <name>scm.home</name>
                  <value>target/scm-it</value>
                </systemProperty>
                <systemProperty>
                  <name>file.encoding</name>
                  <value>UTF-8</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>
              <war>${project.build.directory}/webapp/scm-webapp.war</war>
              <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>
  </profiles>

</project>
