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

    Copyright (c) 2019 - 2024 StreamNative, Inc.. All Rights Reserved.

-->
<!--

    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>4.2.1.7</version>
  <name>StreamNative :: Pulsar Protocol Handler :: KoP Parent</name>
  <description>Parent for Kafka on Pulsar implemented using Pulsar Protocol Handler.</description>
  <url>https://github.com/streamnative/ksn</url>

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

  <scm>
    <url>https://github.com/streamnative/ksn</url>
    <connection>scm:git:https://github.com/streamnative/ksn.git</connection>
    <developerConnection>scm:git:https://github.com/streamnative/ksn.git</developerConnection>
  </scm>

  <developers>
    <developer>
      <organization>StreamNative</organization>
      <organizationUrl>https://streamnative.io/</organizationUrl>
    </developer>
  </developers>

  <properties>
    <client.plugin.compiler.release>8</client.plugin.compiler.release>
    <javac.target>17</javac.target>
    <redirectTestOutputToFile>true</redirectTestOutputToFile>
    <!-- required for running tests on JDK11+ -->
    <test.additional.args>
      --add-opens java.base/jdk.internal.loader=ALL-UNNAMED
      --add-opens java.base/java.lang=ALL-UNNAMED <!--Mockito-->
      --add-opens java.base/java.io=ALL-UNNAMED <!--Bookkeeper NativeIO-->
      --add-opens java.base/java.util=ALL-UNNAMED <!--System Lambda-->
      --add-opens java.base/sun.net=ALL-UNNAMED <!--netty.DnsResolverUtil-->
      --add-opens java.management/sun.management=ALL-UNNAMED <!--JvmDefaultGCMetricsLogger-->
    </test.additional.args>
    <pulsar.group.id>io.streamnative</pulsar.group.id>
    <sn.bom.version>4.2.1.7</sn.bom.version>

    <!-- plugin dependencies -->
    <avro.version>1.12.0</avro.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>
    <maven-javadoc-plugin.version>3.4.1</maven-javadoc-plugin.version>
    <maven-shade-plugin.version>3.4.1</maven-shade-plugin.version>
    <maven-surefire-plugin.version>3.0.0-M3</maven-surefire-plugin.version>
    <puppycrawl.checkstyle.version>10.12.4</puppycrawl.checkstyle.version>
    <spotbugs-maven-plugin.version>4.9.8.1</spotbugs-maven-plugin.version>
    <maven-central-plugin.version>0.7.0</maven-central-plugin.version>
    <maven-jacoco-plugin.version>0.8.8</maven-jacoco-plugin.version>
    <kaml.version>0.53.0</kaml.version>
    <kotlinx-serialization-core.version>1.5.0</kotlinx-serialization-core.version>
    <kotlin.version>1.8.10</kotlin.version>
    <org-json.version>20230227</org-json.version>
  </properties>

  <modules>
    <module>kafka-0-9</module>
    <module>kafka-0-10</module>
    <module>kafka-1-0</module>
    <module>kafka-2-8</module>
    <module>kafka-3-0</module>
    <module>kafka-client-api</module>
    <module>kafka-client-factory</module>
    <module>schema-registry</module>
    <module>kafka-impl</module>
    <module>oauth-client</module>
    <module>oauth-client-shaded</module>
    <module>oauth-client-shaded-test</module>
    <module>kafka-payload-processor</module>
    <module>kafka-payload-processor-shaded</module>
    <module>kafka-payload-processor-shaded-tests</module>
    <module>test-listener</module>
    <module>shadow-namespace-load-manager</module>
    <module>integration-tests</module>
    <module>tests-common</module>
    <module>schema-registry-distribution</module>
    <module>kafka-rest-servlet</module>
    <module>kafka-common</module>
    <module>smoke-tests</module>
    <module>tests</module>
  </modules>

  <!-- dependency definitions -->
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.streamnative</groupId>
        <artifactId>streamnative-bom</artifactId>
        <version>${sn.bom.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>

      <dependency>
        <groupId>io.streamnative.pulsar.handlers</groupId>
        <artifactId>test-listener</artifactId>
        <scope>test</scope>
        <version>${project.version}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <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>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>${maven-javadoc-plugin.version}</version>
        <configuration>
          <source>17</source>
          <doclint>none</doclint>
        </configuration>
      </plugin>

      <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>
          <annotationProcessorPaths>
            <path>
              <groupId>org.projectlombok</groupId>
              <artifactId>lombok</artifactId>
              <version>1.18.38</version>
            </path>
          </annotationProcessorPaths>
          <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>@{argLine} -Xmx2G
            -Dpulsar.allocator.pooled=false
            -Dpulsar.allocator.leak_detection=Advanced
            -Dlog4j.configurationFile="log4j2.xml"
            -Dproject.root="${project.basedir}"
            ${test.additional.args}
          </argLine>
          <reuseForks>false</reuseForks>
          <forkCount>1</forkCount>
          <redirectTestOutputToFile>${redirectTestOutputToFile}</redirectTestOutputToFile>
          <trimStackTrace>false</trimStackTrace>
          <properties>
            <property>
              <name>usedefaultlisteners</name>
              <value>false</value> <!-- disabling default listeners is optional -->
            </property>
            <property>
              <name>listener</name>
              <value>io.streamnative.pulsar.handlers.kop.common.test.TimeOutTestListener</value>
            </property>
          </properties>
        </configuration>
      </plugin>

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

          <excludes>
            <exclude>LICENSE</exclude>
            <exclude>NOTICE</exclude>
            <exclude>Jenkinsfile</exclude>
            <exclude>**/build/**</exclude>
            <exclude>**/ahc.properties</exclude>
            <exclude>**/.idea/**</exclude>
            <exclude>**/.github/**</exclude>
            <exclude>**/conf/**</exclude>
            <exclude>**/bin/**</exclude>
            <exclude>**/swagger/**</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>
          <!-- A workaround to make build work in a Git worktree, see https://github.com/git-commit-id/git-commit-id-maven-plugin/issues/215 -->
          <useNativeGit>true</useNativeGit>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${maven-jacoco-plugin.version}</version>
        <configuration>
          <includes>
            <include>**/pulsar/handlers/**</include>
          </includes>
        </configuration>
        <executions>
          <execution>
            <id>pre-test</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <execution>
            <id>post-test</id>
            <phase>test</phase>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <repositories>
    <repository>
      <id>central</id>
      <layout>default</layout>
      <url>https://repo1.maven.org/maven2</url>
    </repository>
    <!-- maven-central-direct is intentionally not named "central" so that it bypasses
         the google-maven-central mirror configured in CI settings.xml (mirrorOf=central).
         This ensures artifacts not yet synced to the Google mirror (e.g. slog) can still
         be resolved directly from Maven Central. -->
    <repository>
      <id>maven-central-direct</id>
      <url>https://repo1.maven.org/maven2</url>
    </repository>
    <repository>
      <id>github</id>
      <url>https://maven.pkg.github.com/streamnative/*</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
    <repository>
      <id>confluent</id>
      <url>https://packages.confluent.io/maven/</url>
    </repository>
  </repositories>

  <profiles>
    <profile>
      <id>github-deploy</id>
      <distributionManagement>
        <repository>
          <id>github</id>
          <name>GitHub Packages</name>
          <url>https://maven.pkg.github.com/streamnative/pulsar</url>
        </repository>
        <snapshotRepository>
          <id>github</id>
          <name>GitHub Packages</name>
          <url>https://maven.pkg.github.com/streamnative/pulsar</url>
        </snapshotRepository>
      </distributionManagement>
    </profile>
    <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>
            <version>${maven-javadoc-plugin.version}</version>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <source>17</source>
              <doclint>none</doclint>
            </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.central</groupId>
            <artifactId>central-publishing-maven-plugin</artifactId>
            <version>${maven-central-plugin.version}</version>
            <extensions>true</extensions>
            <configuration>
              <publishingServerId>central</publishingServerId>
              <autoPublish>true</autoPublish>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
