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

    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you 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>
    <artifactId>pinot-stream-ingestion</artifactId>
    <groupId>org.apache.pinot</groupId>
    <version>0.11.0</version>
    <relativePath>..</relativePath>
  </parent>

  <artifactId>pinot-kinesis</artifactId>
  <name>Pinot Kinesis</name>
  <url>https://pinot.apache.org/</url>
  <properties>
    <pinot.root>${basedir}/../../..</pinot.root>
    <phase.prop>package</phase.prop>
    <aws.version>2.14.28</aws.version>
    <easymock.version>4.2</easymock.version>
    <reactive.version>1.0.2</reactive.version>
    <localstack-utils.version>0.2.19</localstack-utils.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>software.amazon.awssdk</groupId>
        <artifactId>bom</artifactId>
        <version>${aws.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>sdk-core</artifactId>
      <version>${aws.version}</version>
      <exclusions>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-codec</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-buffer</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-transport</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-common</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>kinesis</artifactId>
      <version>${aws.version}</version>
      <exclusions>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-codec</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-buffer</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-transport</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-common</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>apache-client</artifactId>
      <version>${aws.version}</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
    </dependency>

    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>sts</artifactId>
      <version>${aws.version}</version>
      <exclusions>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-codec</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-buffer</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-transport</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-common</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.reactivestreams</groupId>
      <artifactId>reactive-streams</artifactId>
    </dependency>

    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-codec</artifactId>
    </dependency>

    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-buffer</artifactId>
    </dependency>

    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-codec-http</artifactId>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-codec-http2</artifactId>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-transport</artifactId>
    </dependency>

    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-common</artifactId>
    </dependency>

    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
    </dependency>

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

    <dependency>
      <groupId>cloud.localstack</groupId>
      <artifactId>localstack-utils</artifactId>
      <version>${localstack-utils.version}</version>
      <exclusions>
        <exclusion>
          <groupId>software.amazon.awssdk</groupId>
          <artifactId>*</artifactId>
        </exclusion>
        <!-- We have to explicitly exclude kinesis, due to a bug in the current
             version of the maven-enforcer-plugin, where it doesn't handle
             wildcard exclusions in transitive dependencies. So projects that
             depend on this project wind up not excluding kinesis. -->
        <exclusion>
          <groupId>software.amazon.awssdk</groupId>
          <artifactId>kinesis</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

  </dependencies>
  <profiles>
    <profile>
      <id>build-shaded-jar</id>
      <activation>
        <property>
          <name>skipShade</name>
          <value>!true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.2.1</version>
            <executions>
              <execution>
                <phase>${phase.prop}</phase>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                  <!-- combine.self="override" needs to be specified as without this attribute child pom appears to merge
                   shade plugin configurations in its parents pom.Notably the shade plugin configuration in the root pom declares a mainClass which 
                   causes the build to fail - https://github.com/apache/pinot/blob/master/pom.xml#L1880
                   The build will fail with the message "Unable to parse configuration of mojo org.apache.maven.plugins:maven-shade-plugin:3.2.1:shade 
                   for parameter mainClass: Cannot find 'mainClass' in class org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" error
                   Adding "combine.self" attribute in the child pom's configuration will allow maven to execute the shade plugin independently from the
                   parent pom. For more details please see https://github.com/stevenschlansker/maven-configure-transformer-bug & 
                   https://mail-archives.apache.org/mod_mbox/maven-issues/201605.mbox/%3CJIRA.12964833.1462316804000.103574.1462316952817@Atlassian.JIRA%3E
                   -->
                  <transformers combine.self="override">
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer" />
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                  </transformers>
                  <!--
                  Usually in hadoop environment, there are multiple jars with different versions.
                  Most of the NoSuchMethodExceptions are caused by class loading conflicts.
                  Class relocation ensures the reference of certain packages/classes in Pinot code to
                  shaded libs, e.g. jackson or guava.
                  Ref: https://maven.apache.org/plugins/maven-shade-plugin/examples/class-relocation.html
                  -->
                  <relocations>
                    <relocation>
                      <pattern>com.google.common</pattern>
                      <shadedPattern>${shade.prefix}.com.google.common</shadedPattern>
                    </relocation>
                    <relocation>
                      <pattern>com.fasterxml.jackson</pattern>
                      <shadedPattern>${shade.prefix}.com.fasterxml.jackson</shadedPattern>
                    </relocation>
                    <relocation>
                      <pattern>software.amazon</pattern>
                      <shadedPattern>${shade.prefix}.software.amazon</shadedPattern>
                    </relocation>
                  </relocations>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
