<?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.15.0.7-mapr</version>
  </parent>

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


  <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.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>
      </exclusions>
    </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>**/conffiles</exclude>
            <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>
      </dependencies>
    </profile>

    <profile>
      <id>default-hadoop</id>
      <activation>
        <property>
          <name>!alt-hadoop</name>
        </property>
      </activation>
      <dependencies>
        <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-winutils</artifactId>
          <version>2.7.1</version>
          <type>zip</type>
        </dependency>
      </dependencies>
      <build>
      </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.drill.contrib</groupId>
          <artifactId>drill-auth-mechanism-maprsasl</artifactId>
          <version>${project.version}</version>
        </dependency>
        <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-winutils</artifactId>
          <version>2.7.0-mapr-1506</version>
          <type>zip</type>
        </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>
      </build>
    </profile>
    <profile>
      <id>rpm</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>rpm-maven-plugin</artifactId>
            <version>2.1-alpha-3</version>
            <executions>
              <execution>
                <id>generate-rpm</id>
                <goals>
                  <goal>rpm</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <copyright>2013 ASF</copyright>
              <group>Apache Software Foundation</group>
              <prefix>/opt</prefix>
              <release>SNAPSHOT</release>
              <version>1.0</version>
              <name>drill</name>
              <mappings>
                <mapping>
                  <directory>/opt/drill/bin</directory>
                  <sources>
                    <source>
                      <location>target/drill-${project.version}-bin/drill-${project.version}/bin</location>
                    </source>
                  </sources>
                </mapping>
                <mapping>
                  <directory>/opt/drill/lib</directory>
                  <sources>
                    <source>
                      <location>target/drill-${project.version}-bin/drill-${project.version}/lib</location>
                    </source>
                  </sources>
                </mapping>
                <mapping>
                  <directory>/opt/drill/jars</directory>
                  <sources>
                    <source>
                      <location>target/drill-${project.version}-bin/drill-${project.version}/jars</location>
                    </source>
                  </sources>
                </mapping>
                <mapping>
                  <directory>/etc/drill/conf</directory>
                  <sources>
                    <source>
                      <location>target/drill-${project.version}-bin/drill-${project.version}/conf</location>
                    </source>
                  </sources>
                  <configuration>true</configuration>
                </mapping>
                <mapping>
                  <directory>/etc/init.d/</directory>
                  <sources>
                    <source>
                      <location>src/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.0</version>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>jdeb</goal>
                </goals>
                <configuration>
                  <deb>target/drill-${project.version}.deb</deb>
                  <dataSet>
                    <data>
                      <src>target/drill-${project.version}-bin/drill-${project.version}/lib</src>
                      <type>directory</type>
                      <mapper>
                        <type>perm</type>
                        <prefix>/opt/drill/lib/</prefix>
                      </mapper>
                    </data>
                    <data>
                      <src>target/drill-${project.version}-bin/drill-${project.version}/jars</src>
                      <type>directory</type>
                      <mapper>
                        <type>perm</type>
                        <prefix>/opt/drill/jars/</prefix>
                      </mapper>
                    </data>
                    <data>
                      <src>target/drill-${project.version}-bin/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/drill-${project.version}-bin/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/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>
