<!--
Copyright 2017 Google LLC
Licensed 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>com.google.cloud.bigtable</groupId>
    <artifactId>bigtable-dataflow-parent</artifactId>
    <version>2.12.0</version> <!-- {x-version-update:bigtable-client-parent:current} -->
  </parent>

  <artifactId>bigtable-hbase-beam</artifactId>
  <packaging>jar</packaging>
  <name>${project.groupId}:${project.artifactId}</name>
  <description>
    This project contains artifacts that provide Cloud Bigtable client readers
    and writers in Google Cloud Dataflow.
  </description>

  <dependencyManagement>
    <dependencies>
      <!-- fix conflict beam internal between beam-sdks-java-core & beam-model-pipeline -->
      <dependency>
        <groupId>com.google.errorprone</groupId>
        <artifactId>error_prone_annotations</artifactId>
        <version>2.14.0</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <!-- Beam Group: should come first since we will be running in the beam ecosystem -->
    <dependency>
      <groupId>org.apache.beam</groupId>
      <artifactId>beam-sdks-java-core</artifactId>
      <version>${beam.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.hamcrest</groupId>
          <artifactId>hamcrest</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.apache.beam</groupId>
      <artifactId>beam-sdks-java-io-hbase</artifactId>
      <version>${beam.version}</version>
      <!-- HBaseCoderProviderRegistrar discovered during runtime -->
      <scope>runtime</scope>
      <!-- Let the beam pipeline choose the appropriate slf4j impl.
              Since this is the beam universe, we don't have be a drop in replacement
              for hbase-shaded-client, so we can exclude parts of it that are
              inappropriate for beam-->
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-log4j12</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.hamcrest</groupId>
          <artifactId>hamcrest</artifactId>
        </exclusion>
        <!-- we set our own version of hadoop, excluding to avoid dependency conflicts-->
        <exclusion>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>*</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- Bigtable Group: ordering doesn't matter since everything is shaded -->
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>bigtable-hbase-1.x-shaded</artifactId>
      <version>2.12.0</version> <!-- {x-version-update:bigtable-client-parent:current} -->
      <exclusions>
        <!-- Let the beam pipeline choose the appropriate slf4j impl.
              Since this is the beam universe, we don't have be a drop in replacement
              for hbase-shaded-client, so we can exclude parts of it that are
              inappropriate for beam-->
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-log4j12</artifactId>
        </exclusion>

        <!-- google-cloud-bigtable pulls in a newer version of this, but we want to match beam's version-->
        <exclusion>
          <groupId>org.conscrypt</groupId>
          <artifactId>conscrypt-openjdk-uber</artifactId>
        </exclusion>

        <!-- Workaround MNG-5899 & MSHADE-206. Maven >= 3.3.0 doesn't use the dependency reduced
        pom.xml files when invoking the build from a parent project. So we have to manually exclude
        the dependencies. Note that this works in conjunction with the manually promoted dependencies
        in bigtable-hbase-1.x-shaded/pom.xml -->
        <exclusion>
          <groupId>${project.groupId}</groupId>
          <artifactId>bigtable-hbase-1.x</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.google.cloud.bigtable</groupId>
          <artifactId>bigtable-metrics-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.opencensus</groupId>
          <artifactId>*</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.grpc</groupId>
          <artifactId>grpc-census</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- HBase Group: contains interfaces bigtable-hbase implement -->
    <dependency>
      <groupId>org.apache.hbase</groupId>
      <artifactId>hbase-shaded-client</artifactId>
      <version>${hbase1.version}</version>
      <exclusions>
        <!-- Let the beam pipeline choose the appropriate slf4j impl.
        Since this is the beam universe, we don't have be a drop in replacement
        for hbase-shaded-client, so we can exclude parts of it that are
        inappropriate for beam-->
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-log4j12</artifactId>
        </exclusion>
        <exclusion>
          <groupId>log4j</groupId>
          <artifactId>log4j</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- Misc Group -->
    <dependency>
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>jsr305</artifactId>
      <version>${jsr305.version}</version>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${beam-slf4j.version}</version>
    </dependency>

    <!-- Test Group -->
    <dependency>
      <groupId>org.apache.beam</groupId>
      <artifactId>beam-runners-direct-java</artifactId>
      <version>${beam.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>${mockito.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
      <version>${commons-lang.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-library</artifactId>
      <version>${hamcrest.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-core</artifactId>
      <version>${hamcrest.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>bigtableDataflowIntegrationTest</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <executions>
              <execution>
                <id>api-integration-test</id>
                <goals>
                  <goal>test</goal>
                </goals>
                <phase>none</phase>
              </execution>
              <execution>
                <id>api-gap-test</id>
                <goals>
                  <goal>test</goal>
                </goals>
                <phase>integration-test</phase>
                <configuration>
                  <!-- to enable netty logging, include:
                  -Djava.util.logging.config.file=src/test/resources/logging.properties
                  -->
                  <forkCount>1</forkCount>
                  <includes>
                    <include>**/CloudBigtableIOIntegrationTest.java</include>
                  </includes>
                  <reportNameSuffix>bigtable-server</reportNameSuffix>
                  <systemPropertyVariables>
                    <bigtable.test.extra.resources>
                      bigtable-test.xml
                    </bigtable.test.extra.resources>
                  </systemPropertyVariables>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <configuration>
            <windowtitle>
              Apache Beam + Cloud Bigtable Connector API
            </windowtitle>
            <doctitle>
              Apache Beam + Cloud Bigtable Connector API
            </doctitle>
            <overview>../overview.html</overview>
            <bottom><![CDATA[<br>]]></bottom>

            <offlineLinks>
              <offlineLink>
                <url>
                  https://beam.apache.org/releases/javadoc/${beam.version}/
                </url>
                <location>${basedir}/javadoc/beam-docs</location>
              </offlineLink>
              <offlineLink>
                <url>https://hbase.apache.org/2.0/apidocs/</url>
                <location>${basedir}/javadoc/hbase-docs</location>
              </offlineLink>
            </offlineLinks>
          </configuration>
          <executions>
            <execution>
              <goals>
                <goal>jar</goal>
              </goals>
              <phase>package</phase>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <trimStackTrace>false</trimStackTrace>
        </configuration>
        <executions>
          <execution>
            <id>default-test</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <excludes>
                <exclude>**/*IntegrationTest.java</exclude>
              </excludes>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>com.google.cloud.bigtable.test</groupId>
        <artifactId>bigtable-build-helper</artifactId>
        <version>2.12.0</version> <!-- {x-version-update:bigtable-client-parent:current} -->
        <executions>
          <execution>
            <id>verify-mirror-deps</id>
            <phase>verify</phase>
            <goals>
              <goal>verify-mirror-deps</goal>
            </goals>
            <configuration>
              <targetDependencies>
                <targetDependency>org.apache.beam:beam-sdks-java-core:${beam.version}</targetDependency>
              </targetDependencies>
              <ignoredDependencies>
                <!-- beam's dependency tree has an older version closer higher in the tree -->
                <dependency>com.google.errorprone:error_prone_annotations</dependency>
              </ignoredDependencies>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <executions>
          <!-- Silence checks for old version commons-compress. The the actual
          issue is irrelevant, but fixing it will create real dependency issues
          for end users -->
          <execution>
            <id>enforce-banned-deps</id>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <configuration>
          <ignoredNonTestScopedDependencies>
            <!-- required per verify-mirror-deps-->
            <ignoredNonTestScopedDependency>com.google.code.findbugs:jsr305:*</ignoredNonTestScopedDependency>
          </ignoredNonTestScopedDependencies>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
