<?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">
    <parent>
        <artifactId>kyuubi</artifactId>
        <groupId>yaooqinn</groupId>
        <version>0.7.0-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>kyuubi-server</artifactId>
    <packaging>jar</packaging>
    <name>Kyuubi Project Server</name>

    <dependencies>

        <dependency>
            <groupId>yaooqinn</groupId>
            <artifactId>kyuubi-common</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>${spark.group}</groupId>
            <artifactId>spark-yarn_${scala.binary.version}</artifactId>
        </dependency>

        <dependency>
            <groupId>${spark.group}</groupId>
            <artifactId>spark-hive_${scala.binary.version}</artifactId>
        </dependency>

        <dependency>
            <groupId>${spark.group}</groupId>
            <artifactId>spark-tags_${scala.binary.version}</artifactId>
        </dependency>

        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-client</artifactId>
        </dependency>

        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-servlet</artifactId>
        </dependency>

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

        <dependency>
            <groupId>net.sf.jpam</groupId>
            <artifactId>jpam</artifactId>
        </dependency>

        <dependency>
            <groupId>io.dropwizard.metrics</groupId>
            <artifactId>metrics-core</artifactId>
        </dependency>

        <dependency>
            <groupId>io.dropwizard.metrics</groupId>
            <artifactId>metrics-jvm</artifactId>
        </dependency>

        <dependency>
            <groupId>org.scalatest</groupId>
            <artifactId>scalatest_${scala.binary.version}</artifactId>
        </dependency>

        <dependency>
            <groupId>yaooqinn</groupId>
            <artifactId>kyuubi-common</artifactId>
            <version>${project.version}</version>
            <type>test-jar</type>
        </dependency>

        <dependency>
            <groupId>${spark.group}</groupId>
            <artifactId>spark-core_${scala.binary.version}</artifactId>
            <type>test-jar</type>
        </dependency>
        <dependency>
            <groupId>${spark.group}</groupId>
            <artifactId>spark-catalyst_${scala.binary.version}</artifactId>
            <type>test-jar</type>
        </dependency>
        <dependency>
            <groupId>${spark.group}</groupId>
            <artifactId>spark-sql_${scala.binary.version}</artifactId>
            <type>test-jar</type>
        </dependency>
        <dependency>
            <groupId>${hive.group}</groupId>
            <artifactId>hive-service</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-framework</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-recipes</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-minikdc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.directory.server</groupId>
            <artifactId>apacheds-service</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-test</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-minicluster</artifactId>
        </dependency>
    </dependencies>

    <build>
        <outputDirectory>target/scala-${scala.binary.version}/classes</outputDirectory>
        <testOutputDirectory>target/scala-${scala.binary.version}/test-classes</testOutputDirectory>
        <resources>
            <resource>
                <directory>${project.basedir}/src/main/resources</directory>
            </resource>
            <resource>
                <!-- Include the properties file to provide the build information. -->
                <directory>${project.build.directory}/extra-resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>build-info</id>
                        <phase>generate-resources</phase>
                        <configuration>
                            <target>
                                <exec executable="bash">
                                    <arg value="${project.basedir}/../build/kyuubi-build-info"/>
                                    <arg value="${project.build.directory}/extra-resources"/>
                                    <arg value="${project.version}"/>
                                    <arg value="${spark.version}"/>
                                </exec>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>build-info-test</id>
                        <phase>generate-test-resources</phase>
                        <configuration>
                            <target>
                                <exec executable="bash">
                                    <arg value="${project.basedir}/../build/kyuubi-build-info"/>
                                    <arg value="${project.build.testOutputDirectory}"/>
                                    <arg value="${project.version}"/>
                                    <arg value="${spark.version}"/>
                                </exec>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>fake-jar-test</id>
                        <phase>generate-test-resources</phase>
                        <configuration>
                            <target>
                                <exec executable="touch">
                                    <arg value="${project.build.testOutputDirectory}/kyuubi-server-${project.version}.jar"/>
                                </exec>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>src/gen/java</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <configuration>
                    <shadedArtifactAttached>false</shadedArtifactAttached>
                    <artifactSet>
                        <includes>
                            <include>yaooqinn:kyuubi-common</include>
                        </includes>
                    </artifactSet>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>

                </executions>
            </plugin>

            <!-- disable surefire -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
            </plugin>
            <!-- enable scalatest -->
            <plugin>
                <groupId>org.scalatest</groupId>
                <artifactId>scalatest-maven-plugin</artifactId>
                <version>1.0</version>
                <configuration>
                    <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
                    <junitxml>.</junitxml>
                    <filereports>TestSuite.txt</filereports>
                    <environmentVariables>
                        <KYUUBI_JAR>${project.build.testOutputDirectory}/kyuubi-server-${project.version}.jar</KYUUBI_JAR>
                    </environmentVariables>
                    <systemProperties>
                        <spark.sql.warehouse.dir>${project.build.testOutputDirectory}/spark-warehouse</spark.sql.warehouse.dir>
                        <spark.kyuubi.metrics.reporter>JMX</spark.kyuubi.metrics.reporter>
                    </systemProperties>
                </configuration>
                <executions>
                    <execution>
                        <id>test</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>**/org/apache/hive/service/cli/thrift/*.class</exclude>
                        <exclude>**/org/apache/spark/launcher/*.class</exclude>
                        <exclude>**/org/apache/spark/deploy/*.class</exclude>
                        <exclude>**/org/apache/spark/SparkEnv.class</exclude>
                        <exclude>**/org/apache/spark/SparkEnv$.class</exclude>
                        <exclude>**/org/apache/spark/sql/hive/client/*.class</exclude>
                    </excludes>
                </configuration>
                <executions>
                    <execution>
                        <id>pre-test</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>
</project>