<?xml version="1.0"?>
<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>
  <artifactId>google-cloud-bigtable</artifactId>
  <version>1.14.0</version><!-- {x-version-update:google-cloud-bigtable:current} -->
  <packaging>jar</packaging>
  <name>Google Cloud Bigtable</name>
  <url>https://github.com/googleapis/java-bigtable</url>
  <description>
    Java idiomatic client for Google Cloud Bigtable.
  </description>
  <parent>
    <groupId>com.google.cloud</groupId>
    <artifactId>google-cloud-bigtable-parent</artifactId>
    <version>1.14.0</version><!-- {x-version-update:google-cloud-bigtable:current} -->
  </parent>
  <properties>
    <site.installationModule>google-cloud-bigtable</site.installationModule>

    <!-- Enable the ability to skip unit tests and only run integration tests,
         while still respecting global skipTests override. -->
    <skipTests>false</skipTests>
    <skipUnitTests>${skipTests}</skipUnitTests>
    <skipITs>${skipTests}</skipITs>

    <!-- Use client defined default endpoints -->
    <!-- Can be overriden on the commandline via `-Dbigtable.cfe-data-endpoint=bigtableadmin.googleapis.com:443` -->
    <bigtable.cfe-data-endpoint/>
    <bigtable.cfe-admin-endpoint/>
    <bigtable.directpath-data-endpoint/>
    <bigtable.directpath-admin-endpoint/>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.google.cloud</groupId>
        <artifactId>google-cloud-bigtable-deps-bom</artifactId>
        <version>1.14.0</version><!-- {x-version-update:google-cloud-bigtable:current} -->
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>com.google.cloud</groupId>
        <artifactId>google-cloud-bigtable-bom</artifactId>
        <version>1.14.0</version><!-- {x-version-update:google-cloud-bigtable:current} -->
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <!-- NOTE: Dependencies are organized into two groups, production and test.
         Within a group, dependencies are sorted by (groupId, artifactId) -->

    <!-- Production dependencies -->
    <dependency>
      <groupId>com.google.api</groupId>
      <artifactId>api-common</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.api</groupId>
      <artifactId>gax-grpc</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.api</groupId>
      <artifactId>gax</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.api.grpc</groupId>
      <artifactId>grpc-google-cloud-bigtable-v2</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.api.grpc</groupId>
      <artifactId>proto-google-cloud-bigtable-v2</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.api.grpc</groupId>
      <artifactId>proto-google-cloud-bigtable-admin-v2</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.api.grpc</groupId>
      <artifactId>proto-google-common-protos</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.api.grpc</groupId>
      <artifactId>proto-google-iam-v1</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.auth</groupId>
      <artifactId>google-auth-library-oauth2-http</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.auto.value</groupId>
      <artifactId>auto-value</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.auto.value</groupId>
      <artifactId>auto-value-annotations</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud-core</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>jsr305</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.protobuf</groupId>
      <artifactId>protobuf-java</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.protobuf</groupId>
      <artifactId>protobuf-java-util</artifactId>
    </dependency>
    <dependency>
      <groupId>io.opencensus</groupId>
      <artifactId>opencensus-api</artifactId>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-alts</artifactId>
      <scope>runtime</scope>
    </dependency>
    <!--
      grpc-stub is needed directly by our tests and transitively by grpc-alts at runtime.
      So it has to be declared as a direct dependency and to avoid overriding grpc-alts'
      runtime requirement it has to be promoted to the runtime scope.
    -->
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-stub</artifactId>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-api</artifactId>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-auth</artifactId>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-context</artifactId>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-core</artifactId>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-grpclb</artifactId>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-netty-shaded</artifactId>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-protobuf</artifactId>
    </dependency>
    <dependency>
      <groupId>org.threeten</groupId>
      <artifactId>threetenbp</artifactId>
    </dependency>

    <!-- Test dependencies -->
    <dependency>
      <groupId>com.google.api</groupId>
      <artifactId>gax</artifactId>
      <classifier>testlib</classifier>
      <scope>test</scope>
    </dependency>
    <dependency>
      <!-- Need testing utility classes for generated gRPC clients tests -->
      <groupId>com.google.api</groupId>
      <artifactId>gax-grpc</artifactId>
      <classifier>testlib</classifier>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.api.grpc</groupId>
      <artifactId>grpc-google-cloud-bigtable-admin-v2</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud-bigtable-emulator</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud-conformance-tests</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.truth</groupId>
      <artifactId>truth</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-testing</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.opencensus</groupId>
      <artifactId>opencensus-impl</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-all</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>bigtable-emulator-it</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>

      <build>
        <plugins>
          <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <executions>
              <execution>
                <id>emulator-it</id>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
                <configuration>
                  <skip>false</skip>

                  <systemPropertyVariables>
                    <bigtable.env>emulator</bigtable.env>
                    <bigtable.grpc-log-dir>${project.build.directory}/test-grpc-logs/emulator-it</bigtable.grpc-log-dir>
                  </systemPropertyVariables>
                  <includes>
                    <include>com.google.cloud.bigtable.**.it.*IT</include>
                  </includes>
                  <summaryFile>${project.build.directory}/failsafe-reports/failsafe-summary-emulator-it.xml</summaryFile>
                  <reportsDirectory>${project.build.directory}/failsafe-reports/emulator-it</reportsDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>bigtable-prod-it</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <executions>
              <execution>
                <id>prod-it</id>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
                <configuration>
                  <skip>false</skip>

                  <systemPropertyVariables>
                    <bigtable.env>cloud</bigtable.env>
                    <bigtable.data-endpoint>${bigtable.cfe-data-endpoint}</bigtable.data-endpoint>
                    <bigtable.admin-endpoint>${bigtable.cfe-admin-endpoint}</bigtable.admin-endpoint>
                    <bigtable.grpc-log-dir>${project.build.directory}/test-grpc-logs/prod-it</bigtable.grpc-log-dir>
                  </systemPropertyVariables>
                  <includes>
                    <include>com.google.cloud.bigtable.**.it.*IT</include>
                  </includes>
                  <summaryFile>${project.build.directory}/failsafe-reports/failsafe-summary-prod-it.xml</summaryFile>
                  <reportsDirectory>${project.build.directory}/failsafe-reports/prod-it</reportsDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>bigtable-directpath-it</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <executions>
              <execution>
                <id>directpath-it</id>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
                <configuration>
                  <skip>false</skip>

                  <systemPropertyVariables>
                    <bigtable.env>cloud</bigtable.env>
                    <bigtable.data-endpoint>${bigtable.directpath-data-endpoint}</bigtable.data-endpoint>
                    <bigtable.admin-endpoint>${bigtable.directpath-admin-endpoint}</bigtable.admin-endpoint>
                    <bigtable.grpc-log-dir>${project.build.directory}/test-grpc-logs/directpath-it</bigtable.grpc-log-dir>
                    <bigtable.attempt-directpath>true</bigtable.attempt-directpath>
                  </systemPropertyVariables>
                  <includes>
                    <!-- TODO(igorbernstein): Once the control plane is accessible via directpath, add admin tests -->
                    <include>com.google.cloud.bigtable.data.v2.it.*IT</include>
                  </includes>
                  <summaryFile>${project.build.directory}/failsafe-reports/failsafe-summary-directpath-it.xml</summaryFile>
                  <reportsDirectory>${project.build.directory}/failsafe-reports/directpath-it</reportsDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>3.0.0-M3</version>
        <executions>
          <!-- Prevent users from mistyping a profile name -->
          <execution>
            <id>enforce-valid-profile</id>
            <configuration>
              <rules>
                <requireProfileIdsExist/>
              </rules>
            </configuration>
            <goals>
              <goal>enforce</goal>
            </goals>
          </execution>
          <!-- Ensure that greatest version of each transitive dependency got selected -->
          <execution>
            <id>enforce-dependency-upper-bound</id>
            <configuration>
              <rules>
                <requireUpperBoundDeps/>
              </rules>
            </configuration>
            <goals>
              <goal>enforce</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <configuration>
          <!--
            grpc-grpclb is used at runtime using reflection
            grpc-auth is not directly used transitively, but is pulled to align with other grpc parts
            opencensus-impl-core is brought in transitively through opencensus-impl
            -->
          <usedDependencies>io.grpc:grpc-auth,io.grpc:grpc-grpclb,com.google.auto.value:auto-value</usedDependencies>
          <ignoredUsedUndeclaredDependencies>
            <ignoredUsedUndeclaredDependency>io.opencensus:opencensus-impl-core</ignoredUsedUndeclaredDependency>
          </ignoredUsedUndeclaredDependencies>
        </configuration>
      </plugin>

      <plugin>
        <artifactId>maven-failsafe-plugin</artifactId>
        <configuration>
          <!-- enabled by profiles -->
          <skip>true</skip>

          <parallel>classes</parallel>
          <forkCount>2C</forkCount>
          <threadCount>1</threadCount>
          <reuseForks>true</reuseForks>

          <trimStackTrace>false</trimStackTrace>
        </configuration>
      </plugin>

      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>

        <configuration>
          <!-- enable the ability to skip unit tests, while running integration tests -->
          <skipTests>${skipUnitTests}</skipTests>
          <trimStackTrace>false</trimStackTrace>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
