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

  <artifactId>drill-jdbc-all</artifactId>
  <name>JDBC JAR with all dependencies</name>

  <dependencies>
  
    <!-- start parent dependencies -->
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-handler</artifactId>
      <version>4.0.27.Final</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>14.0.1</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${dep.slf4j.version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jul-to-slf4j</artifactId>
      <version>${dep.slf4j.version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jcl-over-slf4j</artifactId>
      <version>${dep.slf4j.version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>log4j-over-slf4j</artifactId>
      <version>${dep.slf4j.version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>com.googlecode.jmockit</groupId>
      <artifactId>jmockit</artifactId>
      <version>1.3</version>
      <scope>provided</scope>
    </dependency>
    
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${dep.junit.version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>1.9.5</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>1.0.13</version>
      <scope>provided</scope>
    </dependency>
    
    <dependency>
      <groupId>de.huxhorn.lilith</groupId>
      <artifactId>de.huxhorn.lilith.logback.appender.multiplex-classic</artifactId>
      <version>0.9.44</version>
      <scope>provided</scope>
    </dependency>
        
    <!-- end parent dependencies -->
            
    <dependency>
      <groupId>net.hydromatic</groupId>
      <artifactId>optiq-avatica</artifactId>
      <version>0.9-drill-r20</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.drill.exec</groupId>
      <artifactId>drill-java-exec</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <groupId>log4j</groupId>
          <artifactId>log4j</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.hbase</groupId>
          <artifactId>hbase</artifactId>
        </exclusion>
        <exclusion>
          <artifactId>jersey-container-jetty-servlet</artifactId>
          <groupId>org.glassfish.jersey.containers</groupId>
        </exclusion>
        <exclusion>
          <artifactId>jetty-server</artifactId>
          <groupId>org.eclipse.jetty</groupId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-common</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-client</artifactId>
        </exclusion>
        <exclusion>
          <artifactId>jersey-media-multipart</artifactId>
          <groupId>org.glassfish.jersey.media</groupId>
        </exclusion>
        <exclusion>
          <artifactId>jersey-mvc-freemarker</artifactId>
          <groupId>org.glassfish.jersey.ext</groupId>
        </exclusion>
        <exclusion>
          <artifactId>jetty-servlet</artifactId>
          <groupId>org.eclipse.jetty</groupId>
        </exclusion>
        <exclusion>
          <artifactId>parquet-hadoop</artifactId>
          <groupId>com.twitter</groupId>
        </exclusion>
        <exclusion>
          <artifactId>parquet-column</artifactId>
          <groupId>com.twitter</groupId>
        </exclusion>
        <exclusion>
          <artifactId>infinispan-core</artifactId>
          <groupId>org.infinispan</groupId>
        </exclusion>
        <exclusion>
          <artifactId>asm-util</artifactId>
          <groupId>org.ow2.asm</groupId>
        </exclusion>
        <exclusion>
          <artifactId>codemodel</artifactId>
          <groupId>com.sun.codemodel</groupId>
        </exclusion>
        <exclusion>
          <artifactId>asm-commons</artifactId>
          <groupId>org.ow2.asm</groupId>
        </exclusion>
        <exclusion>
          <artifactId>infinispan-tree</artifactId>
          <groupId>org.infinispan</groupId>
        </exclusion>
        <exclusion>
          <artifactId>jetty-util</artifactId>
          <groupId>org.mortbay.jetty</groupId>
        </exclusion>
        <exclusion>
          <artifactId>freemarker</artifactId>
          <groupId>org.freemarker</groupId>
        </exclusion>
        <exclusion>
          <artifactId>hazelcast</artifactId>
          <groupId>com.hazelcast</groupId>
        </exclusion>
        <exclusion>
          <artifactId>commons-compiler-jdk</artifactId>
          <groupId>org.codehaus.janino</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.apache.drill</groupId>
      <artifactId>drill-common</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <artifactId>javassist</artifactId>
          <groupId>javassist</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.apache.drill.exec</groupId>
      <artifactId>drill-jdbc</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <artifactId>drill-storage-hive-core</artifactId>
          <groupId>org.apache.drill.contrib.storage-hive</groupId>
        </exclusion>
        <exclusion>
          <artifactId>foodmart-data-json</artifactId>
          <groupId>net.hydromatic</groupId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.codehaus.janino</groupId>
      <artifactId>janino</artifactId>
      <version>2.6.1</version>
      <scope>provided</scope>
    </dependency>
    <!-- Specify xalan and xerces versions to avoid setXIncludeAware error. -->
    <dependency>
      <groupId>xerces</groupId>
      <artifactId>xercesImpl</artifactId>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <groupId>xml-apis</groupId>
          <artifactId>xml-apis</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>xalan</groupId>
      <artifactId>xalan</artifactId>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <groupId>xml-apis</groupId>
          <artifactId>xml-apis</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>1.0.13</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-core</artifactId>
      <version>1.0.13</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>

      <plugin>
        <groupId>com.github.wvengen</groupId>
        <artifactId>proguard-maven-plugin</artifactId>
        <version>2.0.7</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>proguard</goal>
            </goals>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>net.sf.proguard</groupId>
            <artifactId>proguard-base</artifactId>
            <version>5.0</version>
            <scope>runtime</scope>
          </dependency>
        </dependencies>
        <configuration>
          <proguardVersion>5.0</proguardVersion>
          <obfuscate>false</obfuscate>
          <includeDependencyInjar>true</includeDependencyInjar>
          <outjar>${project.build.finalName}-dirty.jar</outjar>
          <outputDirectory>${project.build.directory}</outputDirectory>
          <maxMemory>6g</maxMemory>
          <options>
            <option>-dontobfuscate</option>
            <option>-dontoptimize</option>
            <option>-ignorewarnings</option>
            <option>-keep class org.apache.drill.exec.proto.** { *; }</option>
            <option>-keep class org.apache.drill.common.types.** { *; }</option>
            <option>-keep class org.apache.drill.jdbc.Driver { *; }</option>
            <option>-keep class org.apache.drill.jdbc.DrillConnection { *; }</option>
            <option>-keep class org.apache.drill.jdbc.DrillStatement { *; }</option>
            <option>-keep class org.apache.drill.jdbc.DrillResultSet { *; }</option>
            <option>-keep class org.apache.drill.jdbc.impl.DrillJdbc40Factory { *; }</option>
            <option>-keep class org.apache.drill.jdbc.impl.DrillJdbc41Factory { *; }</option>
            <option>-keep class org.apache.drill.jdbc.proxy.TracingProxyDriver { *; }</option>
            <option>-keep class org.apache.drill.common.config.CommonConstants { *; }</option>
            <option>-keep class org.apache.drill.common.config.ConfigProvider { *; }</option>
            <option>-keep class org.apache.drill.common.config.DrillConfig { *; }</option>
            <option>-keep class org.apache.drill.common.config.NestedConfig { *; }</option>

            <option>-keep class ch.qos.logback.** { *; }</option>
            <option>-keep class org.slf4j.** { *; }</option>
            <option>-keep class * implements com.fasterxml.jackson.databind.cfg.ConfigFeature { *; }</option>
            <option>-keep class * implements com.fasterxml.jackson.databind.jsontype.TypeIdResolver { *; }</option>
            <!-- do not mess with enums, Java doesn't like it -->
            <option>-keep enum ** { *; }</option>
          </options>
          <exclusions>
            <exclusion>
              <groupId>org.slf4j</groupId>
              <artifactId>jcl-over-slf4j</artifactId>
            </exclusion>
          </exclusions>
          <libs>
            <lib>${java.home}/lib/rt.jar</lib>
            <lib>${java.home}/lib/jsse.jar</lib>
          </libs>
        </configuration>
      </plugin>

      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <configuration>
              <target>
                <delete dir="${project.build.directory}/dirty" />
                <mkdir dir="${project.build.directory}/dirty" />
                <unzip src="${project.build.directory}/${project.build.finalName}-dirty.jar" dest="${project.build.directory}/dirty">
                  <patternset>
                    <exclude name="**/*.java" />
                    <exclude name="org.codehaus.commons.compiler.properties" /> <!-- This leads jad-ui to not parse classes under 'org/' -->
                    <exclude name="**/*.SF" />
                    <exclude name="**/*.RSA" />
                    <exclude name="**/*.DSA" />
                    <exclude name="META-INF/services/*" />
                    <exclude name="META-INF/*.SF" />
                    <exclude name="META-INF/*.RSA" />
                    <exclude name="META-INF/*.DSA" />
                  </patternset>
                </unzip>
                <jar destfile="${project.build.directory}/${project.build.finalName}.jar" basedir="${project.build.directory}/dirty" />
                <delete dir="${project.build.directory}/dirty" />
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

    </plugins>
  </build>

  <pluginRepositories>
    <pluginRepository>
      <id>onejar-maven-plugin.googlecode.com</id>
      <url>http://onejar-maven-plugin.googlecode.com/svn/mavenrepo</url>
    </pluginRepository>
    <pluginRepository>
      <id>scala-tools.org</id>
      <name>Scala-tools Maven2 Repository</name>
      <url>http://scala-tools.org/repo-releases</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>

  <profiles>
    <!-- mondrian data includes 10s of MBs of JSON file
        if you want to include them run maven with -Pwith-mondrian-data -->
    <profile>
      <id>with-mondrian-data</id>
      <activation><activeByDefault>false</activeByDefault></activation>
      <dependencies>
        <dependency>
          <groupId>net.hydromatic</groupId>
          <artifactId>foodmart-queries</artifactId>
          <version>0.4.1</version>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>net.hydromatic</groupId>
          <artifactId>foodmart-data-json</artifactId>
          <version>0.4</version>
        </dependency>
      </dependencies>
    </profile>

    <profile>
      <id>default-hadoop</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <properties>
        <projectVersion>${project.version}</projectVersion>
      </properties>
    </profile>
    <profile>
      <id>mapr</id>
      <properties>
        <projectVersion>${project.version}-mapr</projectVersion>
      </properties>
    </profile>
    <profile>
      <id>cdh</id>
      <properties>
        <projectVersion>${project.version}-mapr</projectVersion>
      </properties>
    </profile>
    <profile>
      <id>hdp</id>
      <properties>
        <projectVersion>${project.version}-hdp</projectVersion>
      </properties>
    </profile>
  </profiles>

</project>
