<?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>paimon-parent</artifactId>
        <groupId>org.apache.paimon</groupId>
        <version>1.3.2</version>
    </parent>

    <artifactId>paimon-format</artifactId>
    <name>Paimon : Format</name>

    <properties>
        <joda-time.version>2.5</joda-time.version>
        <commons.pool.version>1.6</commons.pool.version>
        <commons.lang3.version>3.12.0</commons.lang3.version>
        <storage-api.version>2.8.1</storage-api.version>
        <commons.io.version>2.16.1</commons.io.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.paimon</groupId>
            <artifactId>paimon-common</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.xerial.snappy</groupId>
            <artifactId>snappy-java</artifactId>
            <version>${snappy.version}</version>
        </dependency>

        <dependency>
            <groupId>com.github.luben</groupId>
            <artifactId>zstd-jni</artifactId>
            <version>${zstd-jni.version}</version>
        </dependency>

        <!-- Hadoop -->

        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-common</artifactId>
            <version>${hadoop.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.avro</groupId>
                    <artifactId>avro</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.orc</groupId>
                    <artifactId>orc-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>jdk.tools</groupId>
                    <artifactId>jdk.tools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.protobuf</groupId>
                    <artifactId>protobuf-java</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.commons</groupId>
                    <artifactId>commons-compress</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Orc Start -->

        <dependency>
            <groupId>org.apache.orc</groupId>
            <artifactId>orc-core</artifactId>
            <version>${orc.version}</version>
            <exclusions>
                <!-- Exclude ORC's Hadoop dependency and pull in provided vanilla hadoop. -->
                <exclusion>
                    <groupId>org.apache.hadoop</groupId>
                    <artifactId>hadoop-common</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.hadoop</groupId>
                    <artifactId>hadoop-hdfs</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.activation</groupId>
                    <artifactId>javax.activation-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.xml.bind</groupId>
                    <artifactId>jaxb-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

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

        <dependency>
            <groupId>org.apache.hive</groupId>
            <artifactId>hive-storage-api</artifactId>
            <version>${storage-api.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.hadoop</groupId>
                    <artifactId>hadoop-hdfs</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <version>${protobuf-java.version}</version>
        </dependency>

        <!-- Orc End -->

        <!-- Avro Start -->

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

        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <scope>provided</scope>
            <!-- Avro records can contain JodaTime fields when using logical fields.
                In order to handle them, we need to add an optional dependency.
                Users with those Avro records need to add this dependency themselves. -->
            <optional>true</optional>
            <version>${joda-time.version}</version>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>${commons.io.version}</version>
        </dependency>

        <!-- Avro End -->

        <!-- Parquet Start -->

        <dependency>
            <groupId>org.apache.parquet</groupId>
            <artifactId>parquet-hadoop</artifactId>
            <version>${parquet.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.xerial.snappy</groupId>
                    <artifactId>snappy-java</artifactId>
                </exclusion>
                <exclusion>
                    <artifactId>zstd-jni</artifactId>
                    <groupId>com.github.luben</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.parquet</groupId>
            <artifactId>parquet-column</artifactId>
            <version>${parquet.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.parquet</groupId>
            <artifactId>parquet-common</artifactId>
            <version>${parquet.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.parquet</groupId>
            <artifactId>parquet-encoding</artifactId>
            <version>${parquet.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.parquet</groupId>
            <artifactId>parquet-format-structures</artifactId>
            <version>${parquet.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.parquet</groupId>
            <artifactId>parquet-jackson</artifactId>
            <version>${parquet.version}</version>
        </dependency>

        <dependency>
            <groupId>commons-pool</groupId>
            <artifactId>commons-pool</artifactId>
            <version>${commons.pool.version}</version>
        </dependency>

        <!-- Parquet End -->

        <!-- test dependencies -->

        <dependency>
            <groupId>org.apache.paimon</groupId>
            <artifactId>paimon-test-utils</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.paimon</groupId>
            <artifactId>paimon-common</artifactId>
            <version>${project.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-hdfs</artifactId>
            <version>${hadoop.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-mapreduce-client-core</artifactId>
            <version>${hadoop.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.curator</groupId>
                    <artifactId>curator-test</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.hadoop</groupId>
                    <artifactId>hadoop-yarn-common</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.avro</groupId>
                    <artifactId>avro</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.codehaus.jackson</groupId>
                    <artifactId>jackson-core-asl</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>jdk.tools</groupId>
                    <artifactId>jdk.tools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.parquet</groupId>
            <artifactId>parquet-column</artifactId>
            <version>${parquet.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <executions>
                    <execution>
                        <id>shade-paimon</id>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <artifactSet>
                                <includes combine.children="append">
                                    <!-- Orc -->
                                    <include>org.apache.orc:orc-core</include>
                                    <include>org.apache.orc:orc-shims</include>
                                    <include>org.apache.hive:hive-storage-api</include>
                                    <include>io.airlift:aircompressor</include>
                                    <include>commons-lang:commons-lang</include>
                                    <include>org.apache.commons:commons-lang3</include>
                                    <include>com.google.protobuf:protobuf-java</include>
                                    <include>org.threeten:threeten-extra</include>

                                    <!-- Avro -->
                                    <include>org.apache.avro:avro</include>
                                    <include>com.fasterxml.jackson.core:jackson-core</include>
                                    <include>com.fasterxml.jackson.core:jackson-databind</include>
                                    <include>com.fasterxml.jackson.core:jackson-annotations</include>
                                    <include>org.apache.commons:commons-compress</include>
                                    <include>commons-io:commons-io</include>

                                    <!-- Parquet -->
                                    <include>org.apache.parquet:parquet-hadoop</include>
                                    <include>org.apache.parquet:parquet-format</include>
                                    <include>org.apache.parquet:parquet-column</include>
                                    <include>org.apache.parquet:parquet-common</include>
                                    <include>org.apache.parquet:parquet-encoding</include>
                                    <include>org.apache.parquet:parquet-format-structures</include>
                                    <include>org.apache.parquet:parquet-jackson</include>
                                    <include>commons-pool:commons-pool</include>

                                    <!-- compress -->
                                    <include>com.github.luben:zstd-jni</include>
                                </includes>
                            </artifactSet>
                            <filters>
                                <!-- Another copy of the Apache license, which we don't need. -->
                                <filter>
                                    <artifact>*</artifact>
                                    <excludes>
                                        <exclude>META-INF/LICENSE.txt</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                            <relocations>
                                <!-- Relocate Orc -->
                                <relocation>
                                    <pattern>org.apache.orc</pattern>
                                    <shadedPattern>org.apache.paimon.shade.org.apache.orc</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org.apache.hive</pattern>
                                    <shadedPattern>org.apache.paimon.shade.org.apache.hive</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org.apache.hadoop.hive</pattern>
                                    <shadedPattern>org.apache.paimon.shade.org.apache.hadoop.hive</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>io.airlift</pattern>
                                    <shadedPattern>org.apache.paimon.shade.io.airlift</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>com.google.protobuf</pattern>
                                    <shadedPattern>org.apache.paimon.shade.com.google.protobuf</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org.threeten.extra</pattern>
                                    <shadedPattern>org.apache.paimon.shade.org.threeten.extra</shadedPattern>
                                </relocation>

                                <!-- Relocate Avro. -->
                                <relocation>
                                    <pattern>org.apache.avro</pattern>
                                    <shadedPattern>org.apache.paimon.shade.org.apache.avro</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>com.fasterxml.jackson</pattern>
                                    <shadedPattern>org.apache.paimon.shade.com.fasterxml.jackson</shadedPattern>
                                </relocation>

                                <!-- Relocate parquet. -->
                                <relocation>
                                    <pattern>org.apache.parquet</pattern>
                                    <shadedPattern>org.apache.paimon.shade.org.apache.parquet</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>shaded.parquet</pattern>
                                    <shadedPattern>org.apache.paimon.shade.parquet</shadedPattern>
                                </relocation>

                                <!-- Relocate Common. -->
                                <relocation>
                                    <pattern>org.apache.commons</pattern>
                                    <shadedPattern>org.apache.paimon.shade.org.apache.commons</shadedPattern>
                                </relocation>
                            </relocations>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
