<?xml version="1.0"?>
<!--

    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
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
        xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.apache.pulsar</groupId>
        <artifactId>pulsar</artifactId>
        <version>2.4.1</version>
        <relativePath>..</relativePath>
    </parent>

    <artifactId>managed-ledger</artifactId>
    <name>Managed Ledger</name>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>managed-ledger-original</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>
    <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>
                            <createDependencyReducedPom>true</createDependencyReducedPom>
                            <promoteTransitiveDependencies>true</promoteTransitiveDependencies>

                            <artifactSet>
                                <includes>
                                    <include>org.apache.pulsar:pulsar-client-original</include>
                                    <include>org.apache.pulsar:pulsar-client-admin-original</include>
                                    <include>org.apache.pulsar:managed-ledger-original</include>
                                    <include>org.apache.commons:commons-lang3</include>
                                    <include>commons-codec:commons-codec</include>
                                    <include>commons-collections:commons-collections</include>
                                    <include>org.asynchttpclient:*</include>
                                    <include>io.netty:netty-codec-http</include>
                                    <include>io.netty:netty-transport-native-epoll</include>
                                    <include>org.reactivestreams:reactive-streams</include>
                                    <include>com.typesafe.netty:netty-reactive-streams</include>
                                    <include>org.javassist:javassist</include>
                                    <include>com.google.protobuf:protobuf-java</include>
                                    <include>com.google.guava:guava</include>
                                    <include>com.google.code.gson:gson</include>
                                    <include>com.fasterxml.jackson.core</include>
                                    <include>io.netty:netty</include>
                                    <include>io.netty:netty-all</include>
                                    <include>org.apache.pulsar:pulsar-common</include>
                                    <include>com.yahoo.datasketches:sketches-core</include>
                                    <include>org.glassfish.jersey*:*</include>
                                    <include>javax.ws.rs:*</include>
                                    <include>javax.annotation:*</include>
                                    <include>org.glassfish.hk2*:*</include>
                                    <include>com.fasterxml.jackson.*:*</include>
                                    <include>io.grpc:*</include>
                                    <include>com.yahoo.datasketches:*</include>
                                    <include>io.netty:*</include>
                                    <include>com.squareup.*:*</include>
                                    <include>com.google.*:*</include>
                                    <include>commons-*:*</include>
                                    <include>org.apache.httpcomponents:*</include>
                                    <include>org.eclipse.jetty:*</include>
                                    <include>com.google.auth:*</include>
                                    <include>org.jvnet.mimepull:*</include>
                                    <include>io.opencensus:*</include>
                                    <include>org.apache.zookeeper:*</include>
                                    <include>org.apache.commons:*</include>
                                    <include>net.java.dev.jna:jna</include>
                                    <include>org.apache.yetus:audience-annotations</include>
                                    <include>org.apache.bookkeeper*:*</include>

                                    <include>org.apache.avro:*</include>
                                    <!-- Avro transitive dependencies-->
                                    <include>org.codehaus.jackson:jackson-core-asl</include>
                                    <include>org.codehaus.jackson:jackson-mapper-asl</include>
                                    <include>com.thoughtworks.paranamer:paranamer</include>
                                    <include>org.xerial.snappy:snappy-java</include>
                                    <include>org.apache.commons:commons-compress</include>
                                    <include>org.tukaani:xz</include>
                                </includes>
                            </artifactSet>
                            <filters>
                                <filter>
                                    <artifact>org.apache.pulsar:pulsar-client-original</artifact>
                                    <includes>
                                        <include>**</include>
                                    </includes>
                                </filter>
                            </filters>
                            <relocations>
                                <relocation>
                                    <pattern>org.asynchttpclient</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.org.asynchttpclient</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org.apache.commons</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.org.apache.commons</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>com.google</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.com.google</shadedPattern>
                                    <excludes>
                                        <exclude>com.google.protobuf.*</exclude>
                                    </excludes>
                                </relocation>
                                <relocation>
                                    <pattern>com.fasterxml.jackson</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.com.fasterxml.jackson</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>io.netty</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.io.netty</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org.apache.pulsar.policies</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.org.apache.pulsar.policies</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org.apache.pulsar.checksum</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.org.apache.pulsar.checksum</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>com.yahoo</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.com.yahoo</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>com.typesafe</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.com.typesafe</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org.glassfish</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.org.glassfish</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>javax.ws</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.javax.ws</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>javax.annotation</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.javax.annotation</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>jersey</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.jersey</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org.jvnet</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.org.jvnet</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org.aopalliance</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.org.aopalliance</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>javassist</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.javassist</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>javax.inject</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.javax.inject</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org.reactivestreams</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.org.reactivestreams</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org.apache.avro</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.org.apache.avro</shadedPattern>
                                </relocation>
                                <!-- Avro transitive dependencies-->
                                <relocation>
                                    <pattern>org.codehaus.jackson</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.org.codehaus.jackson</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>com.thoughtworks.paranamer</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.com.thoughtworks.paranamer</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org.xerial.snappy</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.org.xerial.snappy</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org.tukaani</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.org.tukaani</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>io.grpc</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.io.grpc</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>okio</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.okio</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>com.squareup</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.com.squareup</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>io.opencensus</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.io.opencensus</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org.eclipse.jetty</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.org.eclipse.jetty</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org.apache.http</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.org.apache.http</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org.apache.bookkeeper</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.org.apache.bookkeeper</shadedPattern>
                                    <excludes>
                                        <exclude>org.apache.bookkeeper.mledger.**</exclude>
                                    </excludes>
                                </relocation>
                                <relocation>
                                    <pattern>org.apache.zookeeper</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.org.apache.zookeeper</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>net.java.dev.jna</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.net.java.dev.jna</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org.apache.yetus</pattern>
                                    <shadedPattern>org.apache.pulsar.shade.org.apache.yetus</shadedPattern>
                                </relocation>
                            </relocations>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                                <transformer implementation="org.apache.maven.plugins.shade.resource.PluginXmlResourceTransformer" />
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
              <!-- This plugin is used to run a script after the package phase in order to rename
                  libnetty_transport_native_epoll_x86_64.so from Netty into
                  liborg_apache_pulsar_shade_netty_transport_native_epoll_x86_64.so
                  to reflect the shade that is being applied.
               -->
              <artifactId>exec-maven-plugin</artifactId>
              <groupId>org.codehaus.mojo</groupId>
              <executions>
                <execution>
                  <id>rename-epoll-library</id>
                  <phase>package</phase>
                  <goals>
                    <goal>exec</goal>
                  </goals>
                  <configuration>
                    <executable>${project.parent.basedir}/src/${rename.netty.native.libs}</executable>
                    <arguments>
                      <argument>${project.artifactId}</argument>
                    </arguments>
                  </configuration>
                </execution>
              </executions>
            </plugin>
        </plugins>
    </build>
</project>
