<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         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>spark-connectors</artifactId>
    <groupId>com.aliyun.apsaradb</groupId>
    <version>1.0.2</version>
    <relativePath>../pom.xml</relativePath>
  </parent>
  <artifactId>alihbase-spark</artifactId>
  <version>${hbase.version}_${spark.version}-${parent.version}</version>
  <name>Apache HBase - Spark</name>

  <dependencies>
    <!-- we exclude jsr305 below and then expressly relist it as
              provided / optional to avoid dependency resolution possibly
              bringing it back into runtime scope.
         -->
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-core_${scala.binary.version}</artifactId>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <groupId>com.google.code.findbugs</groupId>
          <artifactId>jsr305</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-all</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-sql_${scala.binary.version}</artifactId>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <groupId>com.google.code.findbugs</groupId>
          <artifactId>jsr305</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.scalatest</groupId>
      <artifactId>scalatest_${scala.binary.version}</artifactId>
      <version>${scalatest.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.aliyun.hbase</groupId>
      <artifactId>alihbase-client</artifactId>
      <version>${hbase.version}</version>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-all</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.aliyun.hbase</groupId>
      <artifactId>alihbase-protocol</artifactId>
      <version>${hbase.version}</version>
    </dependency>
    <dependency>
      <groupId>com.aliyun.hbase</groupId>
      <artifactId>alihbase-common</artifactId>
      <version>${hbase.version}</version>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.aliyun.hbase</groupId>
      <artifactId>alihbase-hadoop-compat</artifactId>
      <version>${hbase.version}</version>
      <scope>test</scope>
      <type>test-jar</type>
      <exclusions>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-all</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.aliyun.hbase</groupId>
      <artifactId>alihbase-hadoop2-compat</artifactId>
      <version>${hbase.version}</version>
      <scope>test</scope>
      <type>test-jar</type>
      <exclusions>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-all</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.aliyun.hbase</groupId>
      <artifactId>alihbase-server</artifactId>
      <version>${hbase.version}</version>
      <exclusions>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-all</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.aliyun.hbase</groupId>
      <artifactId>alihbase-server</artifactId>
      <version>${hbase.version}</version>
      <scope>test</scope>
      <type>test-jar</type>
      <exclusions>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-all</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.apache.yetus</groupId>
      <artifactId>audience-annotations</artifactId>
      <version>${audience-annotations.version}</version>
    </dependency>
    <dependency>
      <groupId>com.aliyun.hbase</groupId>
      <artifactId>alihbase-it</artifactId>
      <version>${hbase.version}</version>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-all</artifactId>
      <version>4.1.17.Final</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <testSourceDirectory>src/it/scala</testSourceDirectory>
    <testResources>
      <testResource>
        <directory>src/it/resources</directory>
      </testResource>
    </testResources>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
      </plugin>
      <!-- clover fails due to scala/java cross compile.  This guarantees that the scala is
             compiled before the java that will be evaluated by code coverage (scala will not be).
            https://confluence.atlassian.com/display/CLOVERKB/Java-+Scala+cross-compilation+error+-+cannot+find+symbol
            -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>${maven-build-helper-plugin.version}</version>
        <executions>
          <execution>
            <id>add-source</id>
            <phase>validate</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>src/main/scala</source>
                <source>src/main/java</source>
              </sources>
            </configuration>
          </execution>
          <execution>
            <id>add-test-source</id>
            <phase>validate</phase>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>src/test/scala</source>
                <source>src/it/scala</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <configuration>
          <failOnViolation>true</failOnViolation>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
              <includeScope>runtime</includeScope>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>2.2.1</version>
        <executions>
          <execution>
            <id>attach-sources</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>jar-no-fork</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.4</version>
        <executions>
          <execution>
            <phase>prepare-package</phase>
            <goals>
              <goal>test-jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <!-- Skip the tests in this module -->
    <profile>
      <id>skipSparkTests</id>
      <activation>
        <property>
          <name>skipSparkTests</name>
        </property>
      </activation>
      <properties>
        <surefire.skipFirstPart>true</surefire.skipFirstPart>
        <surefire.skipSecondPart>true</surefire.skipSecondPart>
        <skipTests>true</skipTests>
      </properties>
    </profile>
    <!-- profile against Hadoop 2.x: This is the default. -->
    <profile>
      <id>hadoop-2.0</id>
      <activation>
        <property>
          <!--Below formatting for dev-support/generate-hadoopX-poms.sh-->
          <!--h2-->
          <name>!hadoop.profile</name>
        </property>
      </activation>
      <dependencies>
        <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-client</artifactId>
          <version>${hadoop.version}</version>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-common</artifactId>
          <version>${hadoop.version}</version>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-hdfs</artifactId>
          <version>${hadoop.version}</version>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-auth</artifactId>
          <version>${hadoop.version}</version>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-common</artifactId>
          <version>${hadoop.version}</version>
          <type>test-jar</type>
          <scope>test</scope>
          <exclusions>
            <exclusion>
              <groupId>com.google.code.findbugs</groupId>
              <artifactId>jsr305</artifactId>
            </exclusion>
          </exclusions>
        </dependency>
        <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-hdfs</artifactId>
          <version>${hadoop.version}</version>
          <type>test-jar</type>
          <scope>test</scope>
        </dependency>
      </dependencies>
    </profile>
    <!-- Attempt to skip scala-maven-plugin work, see
    https://github.com/davidB/scala-maven-plugin/issues/198
    -->
    <!-- 'scala.skip' is used by the website generation script on jenkins to
         mitigate the impact of unneeded build forks while building our javadocs.
      -->
    <profile>
      <id>build-scala-sources</id>
      <activation>
        <property>
          <name>scala.skip</name>
          <value>!true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>net.alchim31.maven</groupId>
            <artifactId>scala-maven-plugin</artifactId>
            <version>3.2.0</version>
            <configuration>
              <charset>${project.build.sourceEncoding}</charset>
              <scalaVersion>${scala.version}</scalaVersion>
              <args>
                <arg>-feature</arg>
              </args>
            </configuration>
            <executions>
              <execution>
                <id>scala-compile-first</id>
                <phase>process-resources</phase>
                <goals>
                  <goal>add-source</goal>
                  <goal>compile</goal>
                </goals>
              </execution>
              <execution>
                <id>scala-test-compile</id>
                <phase>process-test-resources</phase>
                <goals>
                  <goal>testCompile</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.scalatest</groupId>
            <artifactId>scalatest-maven-plugin</artifactId>
            <version>${plugins.scalatest.version}</version>
            <configuration>
              <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
              <junitxml>.</junitxml>
              <filereports>WDF TestSuite.txt</filereports>
              <parallel>false</parallel>
            </configuration>
            <executions>
              <execution>
                <id>test</id>
                <phase>test</phase>
                <goals>
                  <goal>test</goal>
                </goals>
                <configuration>
                  <argLine>-Xmx1536m -XX:ReservedCodeCacheSize=512m</argLine>
                  <parallel>false</parallel>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
