<?xml version="1.0" encoding="UTF-8"?>
<!--

    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">

  <parent>
    <groupId>org.apache</groupId>
    <artifactId>apache</artifactId>
    <version>18</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>

  <packaging>pom</packaging>

  <groupId>io.streamnative.pulsar.handlers</groupId>
  <artifactId>pulsar-protocol-handler-kafka-parent</artifactId>
  <version>2.8.1.2</version>
  <name>StreamNative :: Pulsar Protocol Handler :: KoP Parent</name>
  <description>Parent for Kafka on Pulsar implemented using Pulsar Protocol Handler.</description>

  <properties>
    <javac.target>1.8</javac.target>
    <redirectTestOutputToFile>true</redirectTestOutputToFile>

    <!-- dependencies -->
    <commons-lang3.version>3.11</commons-lang3.version>
    <jackson.version>2.12.1</jackson.version>
    <jcommander.version>1.48</jcommander.version>
    <kafka.version>2.0.0</kafka.version>
    <log4j2.version>2.13.3</log4j2.version>
    <lombok.version>1.18.4</lombok.version>
    <mockito.version>2.22.0</mockito.version>
    <pulsar.group.id>io.streamnative</pulsar.group.id>
    <pulsar.version>2.8.1.2</pulsar.version>
    <slf4j.version>1.7.25</slf4j.version>
    <spotbugs-annotations.version>3.1.8</spotbugs-annotations.version>
    <testcontainers.version>1.15.1</testcontainers.version>
    <testng.version>6.14.3</testng.version>
    <avro.version>1.10.2</avro.version>
    <awaitility.version>4.0.3</awaitility.version>
    <!-- plugin dependencies -->
    <dockerfile-maven.version>1.4.9</dockerfile-maven.version>
    <license-maven-plugin.version>3.0.rc1</license-maven-plugin.version>
    <maven-checkstyle-plugin.version>3.1.1</maven-checkstyle-plugin.version>
    <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
    <mavem-shade-plugin.version>3.2.4</mavem-shade-plugin.version>
    <maven-surefire-plugin.version>3.0.0-M3</maven-surefire-plugin.version>
    <os-maven-plugin.version>1.4.1.Final</os-maven-plugin.version>
    <puppycrawl.checkstyle.version>8.37</puppycrawl.checkstyle.version>
    <spotbugs-maven-plugin.version>4.2.2</spotbugs-maven-plugin.version>
    <nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
    <avro.version>1.10.2</avro.version>
  </properties>

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

  <modules>
    <module>kafka-0-10</module>
    <module>kafka-1-0</module>
    <module>kafka-client-api</module>
    <module>kafka-client-factory</module>
    <module>kafka-impl</module>
    <module>oauth-client</module>
    <module>tests</module>
  </modules>

  <!-- dependency definitions -->
  <dependencyManagement>
    <dependencies>
      <!-- provided dependencies -->
      <dependency>
        <groupId>com.github.spotbugs</groupId>
        <artifactId>spotbugs-annotations</artifactId>
        <version>${spotbugs-annotations.version}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <!-- provided dependencies (available at compilation and test classpths and *NOT* packaged) -->
    <dependency>
      <groupId>com.github.spotbugs</groupId>
      <artifactId>spotbugs-annotations</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>${pulsar.group.id}</groupId>
      <artifactId>pulsar-broker</artifactId>
      <version>${pulsar.version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>${pulsar.group.id}</groupId>
      <artifactId>pulsar-broker-common</artifactId>
      <version>${pulsar.version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>${pulsar.group.id}</groupId>
      <artifactId>pulsar-client-original</artifactId>
      <version>${pulsar.version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>${pulsar.group.id}</groupId>
      <artifactId>pulsar-client-admin-original</artifactId>
      <version>${pulsar.version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>${pulsar.group.id}</groupId>
      <artifactId>testmocks</artifactId>
      <version>${pulsar.version}</version>
      <scope>provided</scope>
    </dependency>

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

    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <version>${lombok.version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
      <version>${log4j2.version}</version>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>${jackson.version}</version>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.jackson.dataformat</groupId>
      <artifactId>jackson-dataformat-yaml</artifactId>
      <version>${jackson.version}</version>
    </dependency>

    <dependency>
      <groupId>org.apache.kafka</groupId>
      <artifactId>kafka-clients</artifactId>
      <version>${kafka.version}</version>
    </dependency>

    <dependency>
      <groupId>com.beust</groupId>
      <artifactId>jcommander</artifactId>
      <version>${jcommander.version}</version>
    </dependency>

    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <version>${commons-lang3.version}</version>
    </dependency>

    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-slf4j-impl</artifactId>
      <version>${log4j2.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>${testng.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>${mockito.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>${pulsar.group.id}</groupId>
      <artifactId>pulsar-broker</artifactId>
      <version>${pulsar.version}</version>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>${pulsar.group.id}</groupId>
      <artifactId>managed-ledger</artifactId>
      <version>${pulsar.version}</version>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.avro</groupId>
      <artifactId>avro</artifactId>
      <version>${avro.version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.awaitility</groupId>
      <artifactId>awaitility</artifactId>
      <version>${awaitility.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <version>${maven-checkstyle-plugin.version}</version>
          <dependencies>
            <dependency>
              <groupId>com.puppycrawl.tools</groupId>
              <artifactId>checkstyle</artifactId>
              <version>${puppycrawl.checkstyle.version}</version>
            </dependency>
          </dependencies>
          <configuration>
            <configLocation>resources/checkstyle.xml</configLocation>
            <suppressionsLocation>resources/suppressions.xml</suppressionsLocation>
            <encoding>UTF-8</encoding>
            <consoleOutput>true</consoleOutput>
            <failOnViolation>true</failOnViolation>
            <includeResources>false</includeResources>
            <includeTestSourceDirectory>true</includeTestSourceDirectory>
          </configuration>
          <executions>
            <execution>
              <id>checkstyle</id>
              <phase>validate</phase>
              <goals>
                <goal>check</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>com.github.spotbugs</groupId>
        <artifactId>spotbugs-maven-plugin</artifactId>
        <version>${spotbugs-maven-plugin.version}</version>
        <configuration>
          <excludeFilterFile>resources/findbugsExclude.xml</excludeFilterFile>
        </configuration>
      </plugin>

      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${maven-compiler-plugin.version}</version>
        <configuration>
          <source>${javac.target}</source>
          <target>${javac.target}</target>
          <compilerArgs>
            <!--
            <compilerArg>-Werror</compilerArg>
            -->
            <compilerArg>-Xlint:deprecation</compilerArg>
            <compilerArg>-Xlint:unchecked</compilerArg>
            <!-- https://issues.apache.org/jira/browse/MCOMPILER-205 -->
            <compilerArg>-Xpkginfo:always</compilerArg>
          </compilerArgs>
        </configuration>
      </plugin>

      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${maven-surefire-plugin.version}</version>
        <configuration>
          <argLine> -Xmx2G
            -Dpulsar.allocator.pooled=false
            -Dpulsar.allocator.leak_detection=Advanced
            -Dlog4j.configurationFile="log4j2.xml"
          </argLine>
          <reuseForks>false</reuseForks>
          <forkCount>1</forkCount>
          <redirectTestOutputToFile>${redirectTestOutputToFile}</redirectTestOutputToFile>
          <trimStackTrace>false</trimStackTrace>
        </configuration>
      </plugin>

      <plugin>
        <groupId>com.mycila</groupId>
        <artifactId>license-maven-plugin</artifactId>
        <version>${license-maven-plugin.version}</version>
        <configuration>
          <header>resources/license.template</header>

          <excludes>
            <exclude>LICENSE</exclude>
            <exclude>NOTICE</exclude>
            <exclude>Jenkinsfile</exclude>
            <exclude>resources/license.template</exclude>
            <exclude>**/build/**</exclude>
            <exclude>**/ahc.properties</exclude>
            <exclude>**/.idea/**</exclude>
            <exclude>**/.github/**</exclude>
          </excludes>
          <mapping>
            <proto>JAVADOC_STYLE</proto>
            <go>DOUBLESLASH_STYLE</go>
            <conf>SCRIPT_STYLE</conf>
            <ini>SCRIPT_STYLE</ini>
            <yaml>SCRIPT_STYLE</yaml>
            <tf>SCRIPT_STYLE</tf>
            <cfg>SCRIPT_STYLE</cfg>
            <Makefile>SCRIPT_STYLE</Makefile>
            <service>SCRIPT_STYLE</service>
            <cc>JAVADOC_STYLE</cc>
            <md>XML_STYLE</md>
            <txt>SCRIPT_STYLE</txt>
            <scss>JAVADOC_STYLE</scss>
            <Doxyfile>SCRIPT_STYLE</Doxyfile>
            <tfvars>SCRIPT_STYLE</tfvars>
            <kop>SCRIPT_STYLE</kop>
          </mapping>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>templating-maven-plugin</artifactId>
        <version>1.0.0</version>
        <executions>
          <execution>
            <id>filtering-java-templates</id>
            <goals>
              <goal>filter-sources</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>pl.project13.maven</groupId>
        <artifactId>git-commit-id-plugin</artifactId>
        <version>4.0.0</version>
        <executions>
          <execution>
            <id>get-the-git-infos</id>
            <goals>
              <goal>revision</goal>
            </goals>
            <phase>initialize</phase>
          </execution>
        </executions>
        <configuration>
          <generateGitPropertiesFile>true</generateGitPropertiesFile>
          <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
          <includeOnlyProperties>
            <includeOnlyProperty>^git.build.(host|time|version)$</includeOnlyProperty>
            <includeOnlyProperty>^git.commit.id.(abbrev|full)$</includeOnlyProperty>
            <includeOnlyProperty>^git.dirty$</includeOnlyProperty>
            <includeOnlyProperty>^git.build.user.(email|name)$</includeOnlyProperty>
          </includeOnlyProperties>
          <commitIdGenerationMode>full</commitIdGenerationMode>
        </configuration>
      </plugin>

    </plugins>
  </build>

  <repositories>
    <repository>
      <id>sonatype-streamnative-maven</id>
      <name>sonatype</name>
      <url>https://oss.sonatype.org/content/repositories/iostreamnative-1129</url>
    </repository>

    <repository>
      <id>central</id>
      <layout>default</layout>
      <url>https://repo1.maven.org/maven2</url>
    </repository>
  </repositories>

  <distributionManagement>
    <snapshotRepository>
        <id>ossrh</id>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
        <id>ossrh</id>
        <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>

  <profiles>
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <additionalJOption>-Xdoclint:none</additionalJOption>
            </configuration>
          </plugin>
          <plugin>
            <artifactId>maven-gpg-plugin</artifactId>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <!-- Prevent `gpg` from using pinentry programs -->
              <gpgArguments>
                <arg>--pinentry-mode</arg>
                <arg>loopback</arg>
              </gpgArguments>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <version>${nexus-staging-maven-plugin.version}</version>
            <extensions>true</extensions>
            <configuration>
              <serverId>ossrh</serverId>
              <nexusUrl>https://oss.sonatype.org/</nexusUrl>
              <autoReleaseAfterClose>true</autoReleaseAfterClose>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
