<!--

    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>12</version>
  </parent>

  <groupId>org.commonjava.util</groupId>
  <artifactId>jhttpc</artifactId>
  <version>1.9</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.9</tag>
  </scm>

  <properties>
    <pmd.skip>true</pmd.skip>
    <projectOwner>Red Hat, Inc.</projectOwner>
    <javaVersion>1.7</javaVersion>
    <httpcoreVersion>4.4.6</httpcoreVersion>
    <httpclientVersion>4.5.3</httpclientVersion>
    <dockerWaitFor>Setting LogLevel for all modules to trace6</dockerWaitFor>

    <dockerImage>docker.io/commonjava/ssl-dojo:1.1</dockerImage>
    <dockerStartTimeout>60000</dockerStartTimeout>

    <enforceBestPractices>false</enforceBestPractices>

    <dockerNetwork>default</dockerNetwork>
    <dockerNetworkMode>bridge</dockerNetworkMode>

    <selfsigned-host>localhost</selfsigned-host>
    <rootsigned-host>localhost</rootsigned-host>
    <intersigned-host>localhost</intersigned-host>

    <selfsigned-http-port>${selfsigned-http}</selfsigned-http-port>
    <selfsigned-https-port>${selfsigned-https}</selfsigned-https-port>
    <rootsigned-http-port>${rootsigned-http}</rootsigned-http-port>
    <rootsigned-https-port>${rootsigned-https}</rootsigned-https-port>
    <intersigned-http-port>${intersigned-http}</intersigned-http-port>
    <intersigned-https-port>${intersigned-https}</intersigned-https-port>

    <f8-docker-version>0.15.16</f8-docker-version>

    <plugin.jacoco.skip>false</plugin.jacoco.skip>
  </properties>

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

      <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>${httpclientVersion}</version>
      </dependency>
      <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpcore</artifactId>
        <version>${httpcoreVersion}</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.3</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>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jcl-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>${javaVersion}</source>
            <target>${javaVersion}</target>
          </configuration>
        </plugin>
        <plugin>
          <groupId>io.fabric8</groupId>
          <artifactId>docker-maven-plugin</artifactId>
          <version>${f8-docker-version}</version>
          <configuration>
            <images>
              <image>
                <alias>selfsigned</alias>
                <name>${dockerImage}</name>
                <run>
                  <ports>
                    <port>selfsigned-http:80</port>
                    <port>selfsigned-https:443</port>
                  </ports>
                  <env>
                    <CA_TYPE>self</CA_TYPE>
                    <CA_HOST>test.myco.com</CA_HOST>
                  </env>
                  <wait>
                    <log>${dockerWaitFor}</log>
                    <time>${dockerStartTimeout}</time>
                  </wait>
                  <log>
                    <file>${project.build.directory}/selfsigned.log</file>
                  </log>
                  <network>
                    <mode>${dockerNetworkMode}</mode>
                    <name>${dockerNetwork}</name>
                    <alias>selfsigned</alias>
                  </network>
                </run>
              </image>
              <image>
                <alias>rootsigned</alias>
                <name>${dockerImage}</name>
                <run>
                  <ports>
                    <port>rootsigned-http:80</port>
                    <port>rootsigned-https:443</port>
                  </ports>
                  <env>
                    <CA_TYPE>single</CA_TYPE>
                    <CA_HOST>test.myco.com</CA_HOST>
                  </env>
                  <wait>
                    <log>${dockerWaitFor}</log>
                    <time>${dockerStartTimeout}</time>
                  </wait>
                  <log>
                    <file>${project.build.directory}/rootsigned.log</file>
                  </log>
                  <network>
                    <mode>${dockerNetworkMode}</mode>
                    <name>${dockerNetwork}</name>
                    <alias>rootsigned</alias>
                  </network>
                </run>
              </image>
              <image>
                <alias>intersigned</alias>
                <name>${dockerImage}</name>
                <run>
                  <ports>
                    <port>intersigned-http:80</port>
                    <port>intersigned-https:443</port>
                  </ports>
                  <env>
                    <CA_TYPE>multi</CA_TYPE>
                    <CA_HOST>test.myco.com</CA_HOST>
                  </env>
                  <wait>
                    <log>${dockerWaitFor}</log>
                    <time>${dockerStartTimeout}</time>
                  </wait>
                  <log>
                    <file>${project.build.directory}/intersigned.log</file>
                  </log>
                  <network>
                    <mode>${dockerNetworkMode}</mode>
                    <name>${dockerNetwork}</name>
                    <alias>intersigned</alias>
                  </network>
                </run>
              </image>
            </images>
          </configuration>
          <executions>
            <execution>
              <id>docker-maint</id>
              <goals>
                <goal>start</goal>
                <goal>stop</goal>
                <goal>remove</goal>
              </goals>
            </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=${selfsigned-host}
docker.containers.selfsigned.ports.443/tcp.host=${selfsigned-host}
docker.containers.selfsigned.ports.80/tcp.port=${selfsigned-http-port}
docker.containers.selfsigned.ports.443/tcp.port=${selfsigned-https-port}

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

docker.containers.intersigned.ports.80/tcp.host=${intersigned-host}
docker.containers.intersigned.ports.443/tcp.host=${intersigned-host}
docker.containers.intersigned.ports.80/tcp.port=${intersigned-http-port}
docker.containers.intersigned.ports.443/tcp.port=${intersigned-https-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>ci</id>

<!--       <properties>
        <dockerNetworkMode>custom</dockerNetworkMode>
        <dockerNetwork>ci-network</dockerNetwork>

        <selfsigned-host>${docker.container.selfsigned.net.ci-network.ip}</selfsigned-host>
        <rootsigned-host>${docker.container.rootsigned.net.ci-network.ip}</rootsigned-host>
        <intersigned-host>${docker.container.intersigned.net.ci-network.ip}</intersigned-host>
        <selfsigned-http-port>80</selfsigned-http-port>
        <selfsigned-https-port>443</selfsigned-https-port>
        <rootsigned-http-port>80</rootsigned-http-port>
        <rootsigned-https-port>443</rootsigned-https-port>
        <intersigned-http-port>80</intersigned-http-port>
        <intersigned-https-port>443</intersigned-https-port>
      </properties>

      <build>
        <plugins>
          <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>docker-maven-plugin</artifactId>
          </plugin>
          <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
          </plugin>
          <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
 -->    </profile>
    <profile>
      <id>local-its</id>
      <build>
        <plugins>
          <plugin>
            <groupId>io.fabric8</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>
