<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <artifactId>zeppelin</artifactId>
    <groupId>org.apache.zeppelin</groupId>
    <version>0.12.1</version>
  </parent>

  <artifactId>zeppelin-interpreter-shaded</artifactId>
  <packaging>jar</packaging>
  <name>Zeppelin: Interpreter Shaded</name>
  <description>Zeppelin Interpreter Shaded</description>

  <properties>
    <shaded.dependency.prefix>shaded.org.apache.zeppelin</shaded.dependency.prefix>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.apache.zeppelin</groupId>
      <artifactId>zeppelin-interpreter</artifactId>
      <version>0.12.1</version>
      <optional>true</optional>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <configuration>
          <artifactSet>
            <excludes>
              <!-- Leave slf4j unshaded so downstream users can configure logging. -->
              <exclude>org.slf4j:*</exclude>
              <!-- Leave log4j unshaded so downstream users can configure logging. -->
              <exclude>log4j:log4j</exclude>
              <exclude>ch.qos.reload4j:reload4j</exclude>
            </excludes>
          </artifactSet>
          <filters>
            <filter>
              <artifact>*:*</artifact>
              <excludes>
                <exclude>META-INF/*.SF</exclude>
                <exclude>META-INF/*.DSA</exclude>
                <exclude>META-INF/*.RSA</exclude>
              </excludes>
            </filter>
          </filters>
          <transformers>
            <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
              <resource>reference.conf</resource>
            </transformer>
            <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer"/>
            <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
              <resource>NOTICE.txt</resource>
            </transformer>
            <transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
              <resource>META-INF/LICENSE.txt</resource>
              <file>${basedir}/../../LICENSE.txt</file>
            </transformer>
            <transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
              <resource>META-INF/NOTICE.txt</resource>
              <file>${basedir}/../../NOTICE.txt</file>
            </transformer>
          </transformers>
          <relocations>
            <relocation>
              <pattern>org</pattern>
              <shadedPattern>${shaded.dependency.prefix}.org</shadedPattern>
              <excludes>
                <exclude>org/apache/zeppelin/*</exclude>
                <exclude>org/apache/zeppelin/**/*</exclude>
                <exclude>org/apache/hadoop/*</exclude>
                <exclude>org/apache/hadoop/**</exclude>
                <exclude>org/slf4j/*</exclude>
                <exclude>org/slf4j/**/*</exclude>
                <exclude>org/apache/commons/logging/*</exclude>
                <exclude>org/apache/commons/logging/**/*</exclude>
                <exclude>org/apache/commons/exec/*</exclude>
                <exclude>org/apache/commons/exec/**/*</exclude>
                <exclude>org/apache/log4j/*</exclude>
                <exclude>org/apache/log4j/**/*</exclude>
                <exclude>org/sonatype/*</exclude>
                <exclude>org/sonatype/**/*</exclude>
                <exclude>**/pom.xml</exclude>

                <!-- Not the org/ packages that are a part of the jdk -->
                <exclude>org/ietf/jgss/*</exclude>
                <exclude>org/omg/**/*</exclude>
                <exclude>org/w3c/dom/*</exclude>
                <exclude>org/w3c/dom/**/*</exclude>
                <exclude>org/xml/sax/*</exclude>
                <exclude>org/xml/sax/**/*</exclude>

                <!-- ZEPPELIN-5875 To avoid changing class name improperly between configuration and code
                  `org/apache/zeppelin/shaded/org.apache.zeppelin.shaded.org.eclipse.sisu.space.SisuIndexAPT6`
                  -->
                <exclude>org/eclipse/sisu/**</exclude>
              </excludes>
            </relocation>
            <relocation>
              <pattern>com.google</pattern>
              <shadedPattern>${shaded.dependency.prefix}.com.google</shadedPattern>
            </relocation>
            <relocation>
              <pattern>io</pattern>
              <shadedPattern>${shaded.dependency.prefix}.io</shadedPattern>
            </relocation>
            <relocation>
              <pattern>com.esotericsoftware</pattern>
              <shadedPattern>${shaded.dependency.prefix}.com.esotericsoftware</shadedPattern>
            </relocation>
          </relocations>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-to-interpreter</id>
            <phase>package</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <echo>ANT TASK - clean files....</echo>
                <delete failonerror="false">
                  <fileset dir="${project.basedir}/../interpreter" includes="zeppelin-interpreter-shaded-*.jar" />
                </delete>
                <echo>ANT TASK - copying files....</echo>
                <copy todir="${project.basedir}/../interpreter" overwrite="true" flatten="true">
                  <fileset dir="${project.build.directory}" includes="zeppelin-interpreter-shaded-*.jar" >
                  </fileset>
                </copy>
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>

    </plugins>
  </build>

</project>
