<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright 2020 Terracotta, Inc., a Software AG company.

  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.terracotta</groupId>
    <artifactId>terracotta-utilities-parent</artifactId>
    <version>0.0.16</version>
    <relativePath>..</relativePath>
  </parent>

  <artifactId>terracotta-utilities-port-chooser</artifactId>
  <name>Terracotta Utilities Port Chooser</name>
  <description>Utility classes for TCP port management</description>
  <url>https://github.com/Terracotta-OSS/terracotta-utilities/</url>

  <licenses>
    <license>
      <name>The Apache License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>

  <dependencies>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.terracotta</groupId>
      <artifactId>terracotta-utilities-tools</artifactId>
      <version>${project.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.terracotta</groupId>
      <artifactId>terracotta-utilities-test-tools</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.github.spotbugs</groupId>
      <artifactId>spotbugs-annotations</artifactId>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <!-- Most tests should run with DISABLE_PORT_RELEASE_CHECK false or unset -->
          <excludedEnvironmentVariables>DISABLE_PORT_RELEASE_CHECK</excludedEnvironmentVariables>
        </configuration>
        <executions>
          <execution>
            <!-- Repeat tests using IPv4 preference -->
            <id>IPv4_base</id>
            <configuration>
              <systemPropertyVariables>
                <java.net.preferIPv4Stack>true</java.net.preferIPv4Stack>
                <org.terracotta.disablePortReleaseCheck>false</org.terracotta.disablePortReleaseCheck>
              </systemPropertyVariables>
              <includes>
                <include>org.terracotta.utilities.test.net.*Test</include>
              </includes>
              <excludes>
                <!-- Single test run below. -->
                <exclude>org.terracotta.utilities.test.net.PortManagerTest</exclude>
              </excludes>
              <reportNameSuffix>IPv4_base</reportNameSuffix>
            </configuration>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
          <execution>
            <!-- Repeat tests using IPv4 preference - single test of long-running suite -->
            <id>IPv4_A</id>
            <configuration>
              <systemPropertyVariables>
                <java.net.preferIPv4Stack>true</java.net.preferIPv4Stack>
                <org.terracotta.disablePortReleaseCheck>false</org.terracotta.disablePortReleaseCheck>
              </systemPropertyVariables>
              <test>org.terracotta.utilities.test.net.PortManagerTest#testReleaseCheckEnabled</test>
              <reportNameSuffix>IPv4_A</reportNameSuffix>
            </configuration>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
          <execution>
            <!-- Single test for DISABLE_PORT_RELEASE_CHECK=true -->
            <id>PortCheckDisabled</id>
            <configuration>
              <environmentVariables>
                <DISABLE_PORT_RELEASE_CHECK>true</DISABLE_PORT_RELEASE_CHECK>
              </environmentVariables>
              <test>org.terracotta.utilities.test.net.PortManagerTest#testReleaseCheckDisabledEnvironment</test>
              <reportNameSuffix>PortCheckDisabled</reportNameSuffix>
            </configuration>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <!-- PlantUML diagram generation for javadoc requires Java 11+ -->
      <id>plantuml-diagrams</id>
      <activation>
        <jdk>[11,)</jdk>
        <property>
          <name>maven.javadoc.skip</name>
          <value>!true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>com.github.funthomas424242</groupId>
            <artifactId>plantuml-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>plantuml</id>
                <goals>
                  <goal>generate</goal>
                </goals>
                <phase>generate-sources</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <scm>
    <connection>scm:git:https://github.com/terracotta-oss/terracotta-utilities.git</connection>
    <developerConnection>scm:git:git@github.com:terracotta-oss/terracotta-utilities.git</developerConnection>
    <url>https://github.com/terracotta-oss/terracotta-utilities</url>
  </scm>

  <developers>
    <developer>
      <name>Clifford W Johnson</name>
      <email>clifford.johnson@softwareag.com</email>
      <organization>Terracotta Inc., a wholly-owned subsidiary of Software AG USA, Inc.</organization>
      <organizationUrl>https://terracotta.org</organizationUrl>
    </developer>
  </developers>

</project>