<?xml version="1.0" encoding="UTF-8"?>
<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>com.facebook.presto</groupId>
        <artifactId>presto-root</artifactId>
        <version>0.59</version>
    </parent>

    <artifactId>presto-jdbc</artifactId>
    <name>presto-jdbc</name>

    <properties>
        <air.main.basedir>${project.parent.basedir}</air.main.basedir>
        <shadeBase>com.facebook.presto.jdbc.internal</shadeBase>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.facebook.presto</groupId>
            <artifactId>presto-client</artifactId>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>http-client</artifactId>
            <exclusions>
                <!-- airlift configuration annotations are needed, but bval and cglib are not -->
                <exclusion>
                    <groupId>org.apache.bval</groupId>
                    <artifactId>bval-jsr303</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>cglib</groupId>
                    <artifactId>cglib-nodep</artifactId>
                </exclusion>
                <!-- trace-token is not used -->
                <exclusion>
                    <groupId>io.airlift</groupId>
                    <artifactId>trace-token</artifactId>
                </exclusion>
                <!-- guice is not used -->
                <exclusion>
                    <groupId>javax.inject</groupId>
                    <artifactId>javax.inject</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.inject</groupId>
                    <artifactId>guice</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.inject.extensions</groupId>
                    <artifactId>guice-multibindings</artifactId>
                </exclusion>
                <!-- the apache http client is not used -->
                <exclusion>
                    <groupId>org.apache.httpcomponents</groupId>
                    <artifactId>httpclient</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.httpcomponents</groupId>
                    <artifactId>httpcore</artifactId>
                </exclusion>
                <!-- jmxutils is not used -->
                <exclusion>
                    <groupId>org.weakref</groupId>
                    <artifactId>jmxutils</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>units</artifactId>
            <exclusions>
                <exclusion>
                    <!-- TODO: fix in airlift to be a test dependency -->
                    <groupId>org.apache.bval</groupId>
                    <artifactId>bval-jsr303</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>json</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>javax.inject</groupId>
                    <artifactId>javax.inject</artifactId>
                </exclusion>
                <!-- TODO: fix in airlift to use TypeToken -->
                <!--<exclusion>-->
                    <!--<groupId>com.google.inject</groupId>-->
                    <!--<artifactId>guice</artifactId>-->
                <!--</exclusion>-->
                <exclusion>
                    <groupId>com.google.inject.extensions</groupId>
                    <artifactId>guice-multibindings</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>annotations</artifactId>
        </dependency>

        <!-- for testing -->
        <dependency>
            <groupId>com.facebook.presto</groupId>
            <artifactId>presto-server</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.facebook.presto</groupId>
            <artifactId>presto-server</artifactId>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.facebook.presto</groupId>
            <artifactId>presto-main</artifactId>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- for TestingPrestoServer -->
        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>testing</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <scope>test</scope>
        </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>
                            <shadedArtifactAttached>true</shadedArtifactAttached>
                            <shadedClassifierName>standalone</shadedClassifierName>
                            <createSourcesJar>true</createSourcesJar>
                            <keepDependenciesWithProvidedScope>false</keepDependenciesWithProvidedScope>
                            <artifactSet>
                                <excludes>
                                    <exclude>com.google.code.findbugs:annotations</exclude>
                                    <!-- TODO: remove aopalliance and guice excludes here when excluded above -->
                                    <exclude>aopalliance:aopalliance</exclude>
                                    <exclude>javax.validation:validation-api</exclude>
                                </excludes>
                            </artifactSet>
                            <relocations>
                                <reloation>
                                    <pattern>com.google.inject</pattern>
                                    <shadedPattern>${shadeBase}.guice</shadedPattern>
                                </reloation>
                                <relocation>
                                    <pattern>com.facebook.presto.client</pattern>
                                    <shadedPattern>${shadeBase}.client</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>com.fasterxml.jackson</pattern>
                                    <shadedPattern>${shadeBase}.jackson</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>com.google.common</pattern>
                                    <shadedPattern>${shadeBase}.guava</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>io.airlift</pattern>
                                    <shadedPattern>${shadeBase}.airlift</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org.jboss.netty</pattern>
                                    <shadedPattern>${shadeBase}.netty</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org.joda.time</pattern>
                                    <shadedPattern>${shadeBase}.joda.time</shadedPattern>
                                </relocation>
                            </relocations>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/maven/**</exclude>
                                        <exclude>META-INF/*.xml</exclude>
                                    </excludes>
                                </filter>
                                <filter>
                                    <artifact>com.fasterxml.jackson.core:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/services/**</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
