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

    Copyright 2023 The Fury Authors

    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.furyio</groupId>
    <artifactId>fury-parent</artifactId>
    <version>0.4.1</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>

  <artifactId>fury-format</artifactId>
  <packaging>jar</packaging>

  <scm>
    <url>https://github.com/alipay/fury</url>
    <connection>git@github.com:alipay/fury.git</connection>
    <developerConnection>scm:git:ssh://github.com:alipay/fury.git</developerConnection>
  </scm>
  <developers>
    <developer>
      <organizationUrl>https://furyio.org</organizationUrl>
    </developer>
    <developer>
      <name>chaokunyang</name>
      <email>shawn.ck.yang@gmail.com</email>
      <url>https://github.com/chaokunyang</url>
    </developer>
  </developers>

  <properties>
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.target>8</maven.compiler.target>
    <arrow.version>14.0.0</arrow.version>
    <jackson-bom.version>2.16.0</jackson-bom.version>
    <fury.java.rootdir>${basedir}/..</fury.java.rootdir>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.fasterxml.jackson</groupId>
        <artifactId>jackson-bom</artifactId>
        <version>${jackson-bom.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.furyio</groupId>
      <artifactId>fury-core</artifactId>
      <version>${project.version}</version>
    </dependency>
    <!-- If netty has conflict, users need to exclude packages in their pom -->
    <dependency>
      <groupId>org.apache.arrow</groupId>
      <artifactId>arrow-vector</artifactId>
      <version>${arrow.version}</version>
      <!-- <classifier>shade-format-flatbuffer</classifier> -->
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.arrow</groupId>
      <artifactId>arrow-memory-core</artifactId>
      <version>${arrow.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.arrow</groupId>
      <artifactId>arrow-memory-unsafe</artifactId>
      <version>${arrow.version}</version>
      <scope>runtime</scope>
    </dependency>

    <dependency>
      <groupId>org.furyio</groupId>
      <artifactId>fury-test-core</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>releaseShade</id>
      <activation>
        <property>
          <name>releaseShade</name>
          <value>true</value>
        </property>
      </activation>
      <properties>
        <output.directory>${basedir}</output.directory>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                  <minimizeJar>false</minimizeJar>
                  <artifactSet>
                    <includes>
                      <include>org.codehaus.janino</include>
                      <include>org.apache.arrow</include>
                      <include>io.netty</include>
                    </includes>
                  </artifactSet>
                  <relocations>
                    <relocation>
                      <pattern>org.codehaus</pattern>
                      <shadedPattern>io.fury.shaded.org.codehaus</shadedPattern>
                    </relocation>
                    <relocation>
                      <pattern>org.apache.arrow</pattern>
                      <shadedPattern>io.fury.shaded.org.apache.arrow</shadedPattern>
                    </relocation>
                    <relocation>
                      <pattern>io.netty</pattern>
                      <shadedPattern>io.fury.shaded.io.netty</shadedPattern>
                    </relocation>
                  </relocations>
                  <filters>
                    <filter>
                      <artifact>*:*</artifact>
                      <excludes>
                        <exclude>META-INF/*.SF</exclude>
                        <exclude>META-INF/*.DSA</exclude>
                        <exclude>META-INF/*.RSA</exclude>
                        <exclude>META-INF/**/janino/*</exclude>
                      </excludes>
                    </filter>
                  </filters>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>