<?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>drill-root</artifactId>
    <groupId>org.apache.drill</groupId>
    <version>1.17.0</version>
  </parent>

  <artifactId>distribution</artifactId>
  <packaging>pom</packaging>
  <name>Packaging and Distribution Assembly</name>

  <properties>
    <aws.java.sdk.version>1.11.375</aws.java.sdk.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.apache.drill</groupId>
      <artifactId>drill-protocol</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.drill</groupId>
      <artifactId>drill-logical</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.drill.exec</groupId>
      <artifactId>vector</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.drill.memory</groupId>
      <artifactId>drill-memory-base</artifactId>
      <version>${project.version}</version>
    </dependency>    
    <dependency>
      <groupId>org.apache.drill.exec</groupId>
      <artifactId>drill-rpc</artifactId>
      <version>${project.version}</version>
    </dependency>    
    <dependency>
      <groupId>org.apache.drill.exec</groupId>
      <artifactId>drill-java-exec</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.drill</groupId>
      <artifactId>drill-common</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.drill</groupId>
      <artifactId>drill-yarn</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.drill.exec</groupId>
      <artifactId>drill-jdbc</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.drill.metastore</groupId>
      <artifactId>drill-metastore-api</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.drill.metastore</groupId>
      <artifactId>drill-iceberg-metastore</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-common</artifactId>
      <exclusions>
        <exclusion>
          <groupId>commons-codec</groupId>
          <artifactId>commons-codec</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-aws</artifactId>
      <version>${hadoop.version}</version>
      <exclusions>
        <exclusion>
          <groupId>commons-codec</groupId>
          <artifactId>commons-codec</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.amazonaws</groupId>
          <artifactId>aws-java-sdk-bundle</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk-core</artifactId>
      <version>${aws.java.sdk.version}</version>
      <exclusions>
        <exclusion>
          <artifactId>commons-logging</artifactId>
          <groupId>commons-logging</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk-dynamodb</artifactId>
      <version>${aws.java.sdk.version}</version>
    </dependency>
    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk-sts</artifactId>
      <version>${aws.java.sdk.version}</version>
    </dependency>
    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk-s3</artifactId>
      <version>${aws.java.sdk.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-client</artifactId>
      <exclusions>
        <exclusion>
          <groupId>commons-codec</groupId>
          <artifactId>commons-codec</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.apache.hbase</groupId>
      <artifactId>hbase-client</artifactId>
      <exclusions>
       <exclusion>
           <groupId>io.netty</groupId>
           <artifactId>netty</artifactId>
       </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-tcnative</artifactId>
      <version>2.0.1.Final</version>
      <classifier>linux-x86_64</classifier>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-tcnative</artifactId>
      <version>2.0.1.Final</version>
      <classifier>linux-x86_64-fedora</classifier>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-tcnative</artifactId>
      <version>2.0.1.Final</version>
      <classifier>osx-x86_64</classifier>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-tcnative</artifactId>
      <version>2.0.1.Final</version>
      <classifier>windows-x86_64</classifier>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>de.huxhorn.lilith</groupId>
      <artifactId>de.huxhorn.lilith.logback.appender.multiplex-classic</artifactId>
      <version>0.9.44</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <id>distro-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <descriptors>
                <descriptor>src/assemble/bin-assembly.xml</descriptor>
              </descriptors>
              <appendAssemblyId>false</appendAssemblyId>
              <finalName>apache-drill-${project.version}</finalName>
            </configuration>
          </execution>
          <execution>
            <id>distro-assembly-not-attached</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <attach>false</attach>
              <descriptors>
                <descriptor>src/assemble/bin-assembly-dir.xml</descriptor>
              </descriptors>
              <appendAssemblyId>false</appendAssemblyId>
              <finalName>apache-drill-${project.version}</finalName>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.rat</groupId>
        <artifactId>apache-rat-plugin</artifactId>
        <inherited>true</inherited>
        <configuration>
          <excludes>
            <exclude>**/git.properties</exclude>
            <exclude>**/control</exclude>
            <exclude>**/*.checkstyle</exclude>
            <exclude>**/*.json</exclude>
            <exclude>**/README.md</exclude>
            <exclude>**/hadoop-excludes.txt</exclude>
          </excludes>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <profiles>

    <profile>
      <id>build-jdbc-all</id>
      <activation>
        <property>
          <name>!skipJdbcAll</name>
        </property>
      </activation>
      <dependencies>
        <dependency>
          <groupId>org.apache.drill.exec</groupId>
          <artifactId>drill-jdbc-all</artifactId>
          <version>${project.version}</version>
        </dependency>
      </dependencies>
    </profile>

    <profile>
      <id>build-contrib</id>
      <activation>
        <property>
          <name>!skipContrib</name>
        </property>
      </activation>
      <dependencies>
        <dependency>
          <groupId>org.apache.drill.contrib.data</groupId>
          <artifactId>tpch-sample-data</artifactId>
          <version>${project.version}</version>
        </dependency>
        <dependency>
          <groupId>org.apache.drill.contrib</groupId>
          <artifactId>drill-kudu-storage</artifactId>
          <version>${project.version}</version>
        </dependency>
        <dependency>
          <groupId>org.apache.drill.contrib</groupId>
          <artifactId>drill-opentsdb-storage</artifactId>
          <version>${project.version}</version>
        </dependency>
        <dependency>
          <groupId>org.apache.drill.contrib</groupId>
          <artifactId>drill-mongo-storage</artifactId>
          <version>${project.version}</version>
        </dependency>
        <dependency>
          <groupId>org.apache.drill.contrib</groupId>
          <artifactId>drill-storage-hbase</artifactId>
          <version>${project.version}</version>
          <exclusions>
            <exclusion>
              <groupId>org.apache.hadoop</groupId>
              <artifactId>hadoop-core</artifactId>
            </exclusion>
          </exclusions>
        </dependency>
        <dependency>
          <groupId>org.apache.drill.contrib</groupId>
          <artifactId>drill-jdbc-storage</artifactId>
          <version>${project.version}</version>
        </dependency>
        <dependency>
          <groupId>org.apache.drill.contrib.storage-hive</groupId>
          <artifactId>drill-storage-hive-core</artifactId>
          <version>${project.version}</version>
        </dependency>
	      <dependency>
          <groupId>org.apache.drill.contrib</groupId>
          <artifactId>drill-storage-kafka</artifactId>
          <version>${project.version}</version>
        </dependency>
        <dependency>
          <groupId>org.apache.drill.contrib</groupId>
          <artifactId>drill-udfs</artifactId>
          <version>${project.version}</version>
        </dependency>
        <dependency>
          <groupId>org.apache.drill.contrib</groupId>
          <artifactId>drill-format-syslog</artifactId>
          <version>${project.version}</version>
        </dependency>
        <dependency>
          <groupId>org.apache.drill.contrib</groupId>
          <artifactId>drill-format-ltsv</artifactId>
          <version>${project.version}</version>
        </dependency>
        <dependency>
          <groupId>org.apache.drill.contrib</groupId>
          <artifactId>drill-format-esri</artifactId>
          <version>${project.version}</version>
        </dependency>
        <!--
         drill-format-mapr is intentionally excluded from distribution for the default profile
         to avoid adding mapr-specific jars into jars/3rdparty folder and inflation of the target jar.
         For more details please see DRILL-7213 and DRILL-6929.

         <dependency>
           <groupId>org.apache.drill.contrib</groupId>
           <artifactId>drill-format-mapr</artifactId>
           <version>${project.version}</version>
         </dependency>
         -->
        <dependency>
          <groupId>org.apache.drill.contrib</groupId>
          <artifactId>drill-format-excel</artifactId>
          <version>${project.version}</version>
        </dependency>
      </dependencies>
    </profile>

    <profile>
      <id>default-hadoop</id>
      <activation>
        <property>
          <name>!alt-hadoop</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
              <execution>
                <id>copy-winutils</id>
                <phase>process-resources</phase>
                <goals>
                  <goal>copy-resources</goal>
                </goals>
                <configuration>
                  <outputDirectory>${project.build.directory}/winutils</outputDirectory>
                  <resources>
                    <resource>
                      <directory>src/main/resources/winutils</directory>
                      <filtering>false</filtering>
                    </resource>
                  </resources>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>mapr</id>
      <dependencies>
        <dependency>
          <groupId>org.apache.drill.contrib</groupId>
          <artifactId>drill-format-mapr</artifactId>
          <version>${project.version}</version>
          <exclusions>
            <exclusion>
              <groupId>com.mapr</groupId>
              <artifactId>mapr-test-annotations</artifactId>
            </exclusion>
          </exclusions>
        </dependency>
        <dependency>
          <groupId>org.apache.hbase</groupId>
          <artifactId>hbase-client</artifactId>
        </dependency>
        <dependency>
          <groupId>org.apache.hbase</groupId>
          <artifactId>hbase-annotations</artifactId>
        </dependency>
        <dependency>
          <groupId>org.apache.hbase</groupId>
          <artifactId>hbase-common</artifactId>
        </dependency>
        <dependency>
          <groupId>org.apache.hbase</groupId>
          <artifactId>hbase-protocol</artifactId>
        </dependency>
        <dependency>
          <groupId>org.apache.hive</groupId>
          <artifactId>hive-maprdb-json-handler</artifactId>
        </dependency>
        <dependency>
          <groupId>com.mapr.db</groupId>
          <artifactId>maprdb-mapreduce</artifactId>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
              <execution>
                <id>copy-winutils</id>
                <phase>none</phase>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>3.1.1</version>
            <executions>
              <execution>
                <id>unpack-winutils</id>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <phase>process-resources</phase>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.apache.hadoop</groupId>
                      <artifactId>hadoop-winutils</artifactId>
                      <version>2.7.0-mapr-1506</version>
                      <type>zip</type>
                      <overWrite>true</overWrite>
                      <outputDirectory>${project.build.directory}/winutils</outputDirectory>
                      <excludes>**/*.pdb,**/*.lib,**/*.exp</excludes>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>rpm</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>rpm-maven-plugin</artifactId>
            <version>2.2.0</version>
            <executions>
              <execution>
                <id>generate-rpm</id>
                <goals>
                  <goal>rpm</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <license>${project.organization} ${project.licenses}</license>
              <group>Apache Software Foundation</group>
              <prefix>/opt</prefix>
              <version>${project.version}</version>
              <name>apache-drill</name>
              <mappings>
                <mapping>
                  <directory>/opt/drill</directory>
                  <sources>
                    <source>
                      <location>target/apache-drill-${project.version}/apache-drill-${project.version}/git.properties</location>
                    </source>
                  </sources>
                </mapping>
                <mapping>
                  <directory>/opt/drill</directory>
                  <sources>
                    <source>
                      <location>target/apache-drill-${project.version}/apache-drill-${project.version}/KEYS</location>
                    </source>
                  </sources>
                </mapping>
                <mapping>
                  <directory>/opt/drill</directory>
                  <sources>
                    <source>
                      <location>target/apache-drill-${project.version}/apache-drill-${project.version}/LICENSE</location>
                    </source>
                  </sources>
                </mapping>
                <mapping>
                  <directory>/opt/drill</directory>
                  <sources>
                    <source>
                      <location>target/apache-drill-${project.version}/apache-drill-${project.version}/NOTICE</location>
                    </source>
                  </sources>
                </mapping>
                <mapping>
                  <directory>/opt/drill</directory>
                  <sources>
                    <source>
                      <location>target/apache-drill-${project.version}/apache-drill-${project.version}/README.md</location>
                    </source>
                  </sources>
                </mapping>
                <mapping>
                  <directory>/opt/drill/jars</directory>
                  <sources>
                    <source>
                      <location>target/apache-drill-${project.version}/apache-drill-${project.version}/jars</location>
                    </source>
                  </sources>
                </mapping>
                <mapping>
                  <directory>/opt/drill/bin</directory>
                  <sources>
                    <source>
                      <location>target/apache-drill-${project.version}/apache-drill-${project.version}/bin</location>
                    </source>
                  </sources>
                </mapping>
                <mapping>
		<directory>/opt/drill/sample-data</directory>
                  <sources>
                    <source>
                      <location>target/apache-drill-${project.version}/apache-drill-${project.version}/sample-data</location>
                    </source>
                  </sources>
                </mapping>
                <mapping>
                  <directory>/etc/drill/conf</directory>
                  <sources>
                    <source>
                      <location>target/apache-drill-${project.version}/apache-drill-${project.version}/conf</location>
                    </source>
                  </sources>
                  <configuration>true</configuration>
                </mapping>
                <mapping>
                  <directory>/etc/init.d/</directory>
                  <sources>
                    <source>
                      <location>src/main/resources/drillbit</location>
                    </source>
                  </sources>
                  <directoryIncluded>false</directoryIncluded>
                </mapping>
              </mappings>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>deb</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>jdeb</artifactId>
            <groupId>org.vafer</groupId>
            <version>1.7</version>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>jdeb</goal>
                </goals>
                <configuration>
                  <skipPOMs>false</skipPOMs>
                  <deb>distribution/target/apache-drill-${project.version}/apache-drill-${project.version}.deb</deb>
                  <dataSet>
                    <data>
                      <src>target/apache-drill-${project.version}/apache-drill-${project.version}/git.properties</src>
                      <type>file</type>
                      <mapper>
                        <type>perm</type>
                        <prefix>/opt/drill/</prefix>
                      </mapper>
                    </data>
                    <data>
                      <src>target/apache-drill-${project.version}/apache-drill-${project.version}/KEYS</src>
                      <type>file</type>
                      <mapper>
                        <type>perm</type>
                        <prefix>/opt/drill/</prefix>
                      </mapper>
                    </data>
                    <data>
                      <src>target/apache-drill-${project.version}/apache-drill-${project.version}/LICENSE</src>
                      <type>file</type>
                      <mapper>
                        <type>perm</type>
                        <prefix>/opt/drill/</prefix>
                      </mapper>
                    </data>
                    <data>
                      <src>target/apache-drill-${project.version}/apache-drill-${project.version}/NOTICE</src>
                      <type>file</type>
                      <mapper>
                        <type>perm</type>
                        <prefix>/opt/drill/</prefix>
                      </mapper>
                    </data>
                    <data>
                      <src>target/apache-drill-${project.version}/apache-drill-${project.version}/README.md</src>
                      <type>file</type>
                      <mapper>
                        <type>perm</type>
                        <prefix>/opt/drill/</prefix>
                      </mapper>
                    </data>
                    <data>
                      <src>target/apache-drill-${project.version}/apache-drill-${project.version}/jars</src>
                      <type>directory</type>
                      <mapper>
                        <type>perm</type>
                        <prefix>/opt/drill/jars/</prefix>
                      </mapper>
                    </data>
                    <data>
                      <src>target/apache-drill-${project.version}/apache-drill-${project.version}/bin</src>
                      <type>directory</type>
                      <mapper>
                        <type>perm</type>
                        <prefix>/opt/drill/bin/</prefix>
                        <filemode>755</filemode>
                      </mapper>
                    </data>
                    <data>
                      <src>target/apache-drill-${project.version}/apache-drill-${project.version}/sample-data</src>
                      <type>directory</type>
                      <mapper>
                        <type>perm</type>
                        <prefix>/opt/drill/sample-data</prefix>
                        <filemode>755</filemode>
                      </mapper>
                    </data>
                    <data>
                      <src>target/apache-drill-${project.version}/apache-drill-${project.version}/conf</src>
                      <type>directory</type>
                      <mapper>
                        <type>perm</type>
                        <prefix>/etc/drill/conf</prefix>
                        <filemode>755</filemode>
                      </mapper>
                    </data>
                    <data>
                      <src>src/main/resources/drillbit</src>
                      <dst>/etc/init.d/drillbit</dst>
                      <type>file</type>
                      <mapper>
                        <type>perm</type>
                        <filemode>755</filemode>
                      </mapper>
                    </data>
                  </dataSet>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>docker</id>
      <build>
        <plugins>
          <plugin>
            <groupId>com.spotify</groupId>
            <artifactId>dockerfile-maven-plugin</artifactId>
            <version>1.4.3</version>
            <executions>
              <execution>
                <id>docker-image</id>
                <goals>
                  <goal>build</goal>
                  <goal>push</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <repository>${docker.repository}</repository>
              <tag>${project.version}</tag>
              <buildArgs>
                <VERSION>${project.version}</VERSION>
              </buildArgs>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
