<!--

    Copyright (C) 2015 Red Hat, Inc. (jdcasey@commonjava.org)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<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>
    <groupId>org.commonjava</groupId>
    <artifactId>commonjava</artifactId>
    <version>11</version>
  </parent>

  <groupId>org.commonjava.util</groupId>
  <artifactId>jhttpc</artifactId>
  <version>1.2</version>

  <name>Java HTTP Client</name>
  <inceptionYear>2015</inceptionYear>

  <scm>
    <connection>scm:git:http://github.com/commonjava/jhttpc.git</connection>
    <developerConnection>scm:git:git@github.com:commonjava/jhttpc.git</developerConnection>
    <url>http://github.com/commonjava/jhttpc</url>
    <tag>jhttpc-1.2</tag>
  </scm>

  <properties>
    <projectOwner>Red Hat, Inc.</projectOwner>
    <javaVersion>1.6</javaVersion>
    <httpcVersion>4.4</httpcVersion>
    <dockerWaitFor>Setting LogLevel for all modules to trace6</dockerWaitFor>
    <!-- <dockerImage>docker.io/buildchimp/ssl-dojo:dev</dockerImage> -->
    <dockerImage>docker.io/commonjava/ssl-dojo:1.1</dockerImage>

    <enforceBestPractices>false</enforceBestPractices>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.commonjava.boms</groupId>
        <artifactId>web-commons-bom</artifactId>
        <version>17</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>

      <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>${httpcVersion}</version>
      </dependency>
      <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpcore</artifactId>
        <version>${httpcVersion}</version>
      </dependency>
      <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcprov-jdk15on</artifactId>
        <version>1.53</version>
      </dependency>
      <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcpkix-jdk15on</artifactId>
        <version>1.53</version>
      </dependency>
      <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>1.6</version>
      </dependency>
      <dependency>
        <groupId>org.commonjava.util</groupId>
        <artifactId>http-testserver</artifactId>
        <version>1.1</version>
        <scope>test</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpcore</artifactId>
    </dependency>
    <dependency>
      <groupId>org.bouncycastle</groupId>
      <artifactId>bcprov-jdk15on</artifactId>
    </dependency>
    <dependency>
      <groupId>org.bouncycastle</groupId>
      <artifactId>bcpkix-jdk15on</artifactId>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
    </dependency>
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>log4j-over-slf4j</artifactId>
      <scope>runtime</scope>
    </dependency>

    <!-- Test deps -->
    <dependency>
      <groupId>org.commonjava.util</groupId>
      <artifactId>http-testserver</artifactId>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-core</artifactId>
    </dependency>
    <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>animal-sniffer-maven-plugin</artifactId>
          <version>1.14</version>
          <executions>
            <execution>
              <id>check-jdk16-compat</id>
              <goals>
                <goal>check</goal>
              </goals>
              <phase>test</phase>
              <configuration>
                <signature>
                  <groupId>org.codehaus.mojo.signature</groupId>
                  <artifactId>java16</artifactId>
                  <version>1.1</version>
                </signature>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.8</version>
          <executions>
            <execution>
              <id>default-cli</id>
              <configuration>
                <ignoreNonCompile>true</ignoreNonCompile>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <configuration>
            <source>1.6</source>
            <target>1.6</target>
          </configuration>
        </plugin>
        <plugin>
          <!-- See: https://github.com/wouterd/docker-maven-plugin -->
          <groupId>net.wouterdanes.docker</groupId>
          <artifactId>docker-maven-plugin</artifactId>
          <version>4.0.2-SNAPSHOT</version>
          <executions>
            <execution>
              <id>start-IT-containers</id>
              <goals>
                <goal>start-containers</goal>
              </goals>
              <phase>pre-integration-test</phase>
              <configuration>
                <!-- <forceCleanup>false</forceCleanup> -->
                <providerName>${dockerProvider}</providerName>
                <containers>
                  <container>
                    <id>selfsigned</id>
                    <image>${dockerImage}</image>
                    <env>
                      <CA_TYPE>self</CA_TYPE>
                      <CA_HOST>test.myco.com</CA_HOST>
                    </env>
                    <hostname>test.myco.com</hostname>
                    <waitForStartup>${dockerWaitFor}</waitForStartup>
                  </container>
                  <container>
                    <id>rootsigned</id>
                    <image>${dockerImage}</image>
                    <env>
                      <CA_TYPE>single</CA_TYPE>
                      <CA_HOST>test.myco.com</CA_HOST>
                    </env>
                    <hostname>test.myco.com</hostname>
                    <waitForStartup>${dockerWaitFor}</waitForStartup>
                  </container>
                  <container>
                    <id>intersigned</id>
                    <image>${dockerImage}</image>
                    <env>
                      <CA_TYPE>multi</CA_TYPE>
                      <CA_HOST>test.myco.com</CA_HOST>
                    </env>
                    <hostname>test.myco.com</hostname>
                    <waitForStartup>${dockerWaitFor}</waitForStartup>
                  </container>
                </containers>
              </configuration>
            </execution>
            <execution>
              <id>stop-IT-containers</id>
              <goals>
                <goal>stop-containers</goal>
              </goals>
              <phase>post-integration-test</phase>
              <configuration>
                <logs>${project.build.directory}/docker-logs</logs>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.8</version>
          <executions>
            <execution>
              <id>record-docker-properties</id>
              <goals>
                <goal>run</goal>
              </goals>
              <phase>pre-integration-test</phase>
              <configuration>
                <target>
                  <echo file="${project.build.directory}/docker.properties">
                    <![CDATA[
docker.containers.selfsigned.ports.80/tcp.host=${docker.containers.selfsigned.ports.80/tcp.host}
docker.containers.selfsigned.ports.443/tcp.host=${docker.containers.selfsigned.ports.443/tcp.host}
docker.containers.selfsigned.ports.80/tcp.port=${docker.containers.selfsigned.ports.80/tcp.port}
docker.containers.selfsigned.ports.443/tcp.port=${docker.containers.selfsigned.ports.443/tcp.port}

docker.containers.rootsigned.ports.80/tcp.host=${docker.containers.rootsigned.ports.80/tcp.host}
docker.containers.rootsigned.ports.443/tcp.host=${docker.containers.rootsigned.ports.443/tcp.host}
docker.containers.rootsigned.ports.80/tcp.port=${docker.containers.rootsigned.ports.80/tcp.port}
docker.containers.rootsigned.ports.443/tcp.port=${docker.containers.rootsigned.ports.443/tcp.port}

docker.containers.intersigned.ports.80/tcp.host=${docker.containers.intersigned.ports.80/tcp.host}
docker.containers.intersigned.ports.443/tcp.host=${docker.containers.intersigned.ports.443/tcp.host}
docker.containers.intersigned.ports.80/tcp.port=${docker.containers.intersigned.ports.80/tcp.port}
docker.containers.intersigned.ports.443/tcp.port=${docker.containers.intersigned.ports.443/tcp.port}

javax.net.debug=ssl:handshake:verbose
]]>
                  </echo>
                </target>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>2.19</version>
          <executions>
            <execution>
              <id>functional-tests</id>
              <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
              </goals>
              <configuration>
                <includes>
                  <include>**/*IT.java</include>
                </includes>
                <forkCount>1C</forkCount>
                <redirectTestOutputToFile>true</redirectTestOutputToFile>
                <systemPropertiesFile>${project.build.directory}/docker.properties</systemPropertiesFile>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>animal-sniffer-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>local-its</id>

      <properties>
        <dockerProvider>local</dockerProvider>
      </properties>

      <build>
        <plugins>
          <plugin>
            <groupId>net.wouterdanes.docker</groupId>
            <artifactId>docker-maven-plugin</artifactId>
          </plugin>
          <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
          </plugin>
          <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
