<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
  <parent>
    <artifactId>ratis-thirdparty</artifactId>
    <groupId>org.apache.ratis</groupId>
    <version>0.5.0</version>
    <relativePath>../../pom.xml</relativePath>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>ratis-thirdparty-misc</artifactId>
  <name>Apache Ratis Thirdparty Miscellaneous</name>
  <description>Miscellaneous thirdparty dependencies for Apache Ratis</description>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-shade-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <shadeSourcesContent>true</shadeSourcesContent>
              <createSourcesJar>true</createSourcesJar>
              <shadedArtifactAttached>false</shadedArtifactAttached>
              <dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
              <relocations>
                <relocation>
                  <pattern>com.google.api</pattern>
                  <shadedPattern>${ratis.thirdparty.shaded.prefix}.com.google.api</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>com.google.cloud.audit</pattern>
                  <shadedPattern>${ratis.thirdparty.shaded.prefix}.com.google.cloud.audit</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>com.google.common</pattern>
                  <shadedPattern>${ratis.thirdparty.shaded.prefix}.com.google.common</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>com.google.logging.type</pattern>
                  <shadedPattern>${ratis.thirdparty.shaded.prefix}.com.google.logging.type</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>com.google.longrunning</pattern>
                  <shadedPattern>${ratis.thirdparty.shaded.prefix}.com.google.longrunning</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>com.google.protobuf</pattern>
                  <shadedPattern>${ratis.thirdparty.shaded.prefix}.com.google.protobuf</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>com.google.rpc</pattern>
                  <shadedPattern>${ratis.thirdparty.shaded.prefix}.com.google.rpc</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>com.google.thirdparty.publicsuffix</pattern>
                  <shadedPattern>${ratis.thirdparty.shaded.prefix}.com.google.thirdparty.publicsuffix</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>com.google.type</pattern>
                  <shadedPattern>${ratis.thirdparty.shaded.prefix}.com.google.type</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>io.grpc</pattern>
                  <shadedPattern>${ratis.thirdparty.shaded.prefix}.io.grpc</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>com.google.flatbuffers</pattern>
                  <shadedPattern>${ratis.thirdparty.shaded.prefix}.com.google.flatbuffers</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>io.netty</pattern>
                  <shadedPattern>${ratis.thirdparty.shaded.prefix}.io.netty</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>io.opencensus</pattern>
                  <shadedPattern>${ratis.thirdparty.shaded.prefix}.io.opencensus</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>com.google.gson</pattern>
                  <shadedPattern>${ratis.thirdparty.shaded.prefix}.com.google.gson</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>afu</pattern>
                  <shadedPattern>${ratis.thirdparty.shaded.prefix}.afu</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>org.checkerframework</pattern>
                  <shadedPattern>${ratis.thirdparty.shaded.prefix}.org.checkerframework</shadedPattern>
                </relocation>
              </relocations>
              <filters>
                <filter>
                  <artifact>io.netty:netty-tcnative-boringssl-static</artifact>
                  <excludes>
                    <exclude>META-INF/native/libnetty_tcnative_linux_x86_64.so</exclude>
                    <exclude>META-INF/native/netty_tcnative_windows_x86_64.dll</exclude>
                    <exclude>META-INF/native/libnetty_tcnative_osx_x86_64.jnilib</exclude>
                  </excludes>
                </filter>
              </filters>
              <artifactSet>
                <includes>
                  <include>*:*</include>
                </includes>
                <excludes>
                  <exclude>com.google.code.findbugs:jsr305</exclude>
                  <exclude>com.google.errorprone:error_prone_annotations</exclude>
                  <exclude>com.google.j2objc:j2objc-annotations</exclude>
                  <exclude>io.netty:netty-buffer</exclude>
                  <exclude>io.netty:netty-codec-http2</exclude>
                  <exclude>io.netty:netty-codec-http</exclude>
                  <exclude>io.netty:netty-codec-socks</exclude>
                  <exclude>io.netty:netty-codec</exclude>
                  <exclude>io.netty:netty-common</exclude>
                  <exclude>io.netty:netty-handler-proxy</exclude>
                  <exclude>io.netty:netty-handler</exclude>
                  <exclude>io.netty:netty-resolver</exclude>
                  <exclude>io.netty:netty-transport</exclude>
                  <exclude>org.codehaus.mojo:animal-sniffer-annotations</exclude>
                </excludes>
              </artifactSet>
              <transformers>
                <transformer />
              </transformers>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.0.2</version>
        <executions>
          <execution>
            <id>unpack-dependencies</id>
            <phase>validate</phase>
            <goals>
              <goal>unpack-dependencies</goal>
            </goals>
            <configuration>
              <includeGroupIds>io.netty</includeGroupIds>
              <includeArtifactIds>netty-tcnative-boringssl-static</includeArtifactIds>
              <includes>**/META-INF/native/*</includes>
              <outputDirectory>${project.build.directory}/classes/</outputDirectory>
              <overWriteReleases>true</overWriteReleases>
              <overWriteSnapshots>true</overWriteSnapshots>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.coderplus.maven.plugins</groupId>
        <artifactId>copy-rename-maven-plugin</artifactId>
        <version>1.0</version>
        <executions>
          <execution>
            <id>rename-file</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>rename</goal>
            </goals>
            <configuration>
              <fileSets>
                <fileSet>
                  <sourceFile>${project.build.directory}/classes/META-INF/native/libnetty_tcnative_linux_x86_64.so</sourceFile>
                  <destinationFile>${project.build.directory}/classes/META-INF/native/lib${ratis.thirdparty.shaded.native.prefix}netty_tcnative_linux_x86_64.so</destinationFile>
                </fileSet>
                <fileSet>
                  <sourceFile>${project.build.directory}/classes/META-INF/native/netty_tcnative_windows_x86_64.dll</sourceFile>
                  <destinationFile>${project.build.directory}/classes/META-INF/native/${ratis.thirdparty.shaded.native.prefix}netty_tcnative_windows_x86_64.dll</destinationFile>
                </fileSet>
                <fileSet>
                  <sourceFile>${project.build.directory}/classes/META-INF/native/libnetty_tcnative_osx_x86_64.jnilib</sourceFile>
                  <destinationFile>${project.build.directory}/classes/META-INF/native/lib${ratis.thirdparty.shaded.native.prefix}netty_tcnative_osx_x86_64.jnilib</destinationFile>
                </fileSet>
              </fileSets>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
