<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2025 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

    https://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>
    <artifactId>cassandra-bigtable-java-client-parent</artifactId>
    <groupId>com.google.cloud</groupId>
    <version>0.3.0</version><!-- {x-version-update:cassandra-bigtable-java-client-parent:current} -->
  </parent>

  <artifactId>cassandra-bigtable-java-client-lib</artifactId>
  <packaging>jar</packaging>
  <version>0.3.0</version><!-- {x-version-update:cassandra-bigtable-java-client-lib:current} -->
  <description>
    Bigtable CQL Client for Java library
  </description>
  <name>Cassandra Bigtable Java Client Library</name>

  <properties>
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.target>8</maven.compiler.target>
    <skipIntegrationTests>true</skipIntegrationTests>
    <netty.version>4.1.123.Final</netty.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava-bom</artifactId>
        <version>33.4.6-jre</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit-bom</artifactId>
        <version>5.12.1</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.apache.cassandra</groupId>
      <artifactId>java-driver-core</artifactId>
      <version>4.19.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.yaml</groupId>
      <artifactId>snakeyaml</artifactId>
      <version>2.4</version>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
    </dependency>
    <dependency>
      <groupId>net.java.dev.jna</groupId>
      <artifactId>jna</artifactId>
      <version>5.17.0</version>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-transport-native-epoll</artifactId>
      <version>${netty.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-transport-native-kqueue</artifactId>
      <version>${netty.version}</version>
      <scope>provided</scope>
    </dependency>
    <!-- Logging dependencies -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>2.0.17</version>
    </dependency>
    <!-- Test dependencies -->
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.vintage</groupId>
      <artifactId>junit-vintage-engine</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-jdk14</artifactId>
      <version>2.0.17</version>
      <scope>test</scope>
    </dependency>
    <!-- Compilation dependencies -->
    <dependency>
      <groupId>com.google.auto.value</groupId>
      <artifactId>auto-value-annotations</artifactId>
      <version>1.11.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>net.jcip</groupId>
      <artifactId>jcip-annotations</artifactId>
      <version>1.0</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>

  <profiles>
    <!-- linux/amd64 -->
    <profile>
      <id>linux-amd64</id>
      <properties>
        <classifierName>linux-amd64</classifierName>
      </properties>
      <dependencies>
        <dependency>
          <groupId>com.google.cloud</groupId>
          <artifactId>cassandra-bigtable-java-client-core</artifactId>
          <version>0.3.0</version><!-- {x-version-update:cassandra-bigtable-java-client-core:current} -->
          <classifier>linux-amd64</classifier>
        </dependency>
        <dependency>
          <groupId>io.netty</groupId>
          <artifactId>netty-transport-native-epoll</artifactId>
          <version>${netty.version}</version>
          <classifier>linux-x86_64</classifier>
        </dependency>
      </dependencies>
    </profile>

    <!-- linux/arm64 -->
    <profile>
      <id>linux-arm64</id>
      <properties>
        <classifierName>linux-arm64</classifierName>
      </properties>
      <dependencies>
        <dependency>
          <groupId>com.google.cloud</groupId>
          <artifactId>cassandra-bigtable-java-client-core</artifactId>
          <version>0.3.0</version><!-- {x-version-update:cassandra-bigtable-java-client-core:current} -->
          <classifier>linux-arm64</classifier>
        </dependency>
        <dependency>
          <groupId>io.netty</groupId>
          <artifactId>netty-transport-native-epoll</artifactId>
          <version>${netty.version}</version>
          <classifier>linux-aarch_64</classifier>
        </dependency>
      </dependencies>
    </profile>

    <!-- darwin/amd64 -->
    <profile>
      <id>darwin-amd64</id>
      <properties>
        <classifierName>darwin-amd64</classifierName>
      </properties>
      <dependencies>
        <dependency>
          <groupId>com.google.cloud</groupId>
          <artifactId>cassandra-bigtable-java-client-core</artifactId>
          <version>0.3.0</version><!-- {x-version-update:cassandra-bigtable-java-client-core:current} -->
          <classifier>darwin-amd64</classifier>
        </dependency>
        <dependency>
          <groupId>io.netty</groupId>
          <artifactId>netty-transport-native-kqueue</artifactId>
          <version>${netty.version}</version>
          <classifier>osx-x86_64</classifier>
        </dependency>
      </dependencies>
    </profile>

    <!-- darwin/arm64 -->
    <profile>
      <id>darwin-arm64</id>
      <properties>
        <classifierName>darwin-arm64</classifierName>
      </properties>
      <dependencies>
        <dependency>
          <groupId>com.google.cloud</groupId>
          <artifactId>cassandra-bigtable-java-client-core</artifactId>
          <version>0.3.0</version><!-- {x-version-update:cassandra-bigtable-java-client-core:current} -->
          <classifier>darwin-arm64</classifier>
        </dependency>
        <dependency>
          <groupId>io.netty</groupId>
          <artifactId>netty-transport-native-kqueue</artifactId>
          <version>${netty.version}</version>
          <classifier>osx-aarch_64</classifier>
        </dependency>
      </dependencies>
    </profile>
  </profiles>

  <build>
    <resources>
      <!--Copy project.properties file-->
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
      <!-- Copy third-party licenses-->
      <resource>
        <directory>${project.basedir}/third_party</directory>
        <includes>
          <include>**/*</include>
        </includes>
        <targetPath>third_party</targetPath>
      </resource>
    </resources>

    <plugins>
      <!-- Enforce active profile-->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>3.4.1</version>
        <executions>
          <execution>
            <id>enforce-active-profile</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <phase>validate</phase>
            <configuration>
              <rules>
                <requireActiveProfile>
                  <profiles>linux-amd64,linux-arm64,darwin-amd64,darwin-arm64</profiles>
                  <all>false</all>
                </requireActiveProfile>
              </rules>
              <fail>true</fail>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Compile code -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.14.0</version>
        <configuration>
          <annotationProcessorPaths>
            <path>
              <groupId>com.google.auto.value</groupId>
              <artifactId>auto-value</artifactId>
              <version>1.11.0</version>
            </path>
          </annotationProcessorPaths>
        </configuration>
      </plugin>

      <!-- Unit tests -->
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.5.3</version>
      </plugin>

      <!-- Integration tests -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>3.5.3</version>
        <dependencies>
          <dependency>
            <groupId>org.apache.maven.surefire</groupId>
            <artifactId>surefire-junit-platform</artifactId>
            <version>3.5.3</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
            <configuration>
              <skipITs>${skipIntegrationTests}</skipITs>
              <includes>
                <include>**/SmokeTestIT.java</include>
              </includes>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <!-- Used by auto-value to ensure API backwards compatability -->
        <artifactId>clirr-maven-plugin</artifactId>
        <configuration>
          <excludes>
            <!-- Exclude this configuration because no end users are expected to extend it -->
            <exclude>com/google/bigtable/cassandra/BigtableCqlConfiguration</exclude>
          </excludes>
        </configuration>
      </plugin>
      <!-- Packaging -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.6.0</version>
        <executions>
          <execution>
            <id>${classifierName}</id>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <shadedArtifactAttached>true</shadedArtifactAttached>
              <shadedClassifierName>${classifierName}</shadedClassifierName>
              <createDependencyReducedPom>false</createDependencyReducedPom>
              <artifactSet>
                <excludes>
                  <exclude>com.google.code.findbugs:annotations</exclude>
                </excludes>
                <includes>
                  <include>com.google.cloud:cassandra-bigtable-java-client-core:${classifierName}</include>
                  <include>*:*:jar:*</include>
                </includes>
              </artifactSet>
              <filters>
                <filter>
                  <artifact>*:*</artifact>
                  <excludes>
                    <exclude>META-INF/*.SF</exclude>
                    <exclude>META-INF/*.DSA</exclude>
                    <exclude>META-INF/*.RSA</exclude>
                    <exclude>META-INF/MANIFEST.MF</exclude>
                    <exclude>module-info.class</exclude>
                  </excludes>
                </filter>
              </filters>
              <transformers>
                <transformer
                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"/>
                <transformer
                    implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer"/>
                <transformer
                    implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                <transformer
                    implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer">
                  <addHeader>false</addHeader>
                </transformer>
              </transformers>
            </configuration>
          </execution>
        </executions>
      </plugin>

    </plugins>
  </build>

</project>
