<?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

      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>
  <groupId>com.google.cloud</groupId>
  <artifactId>google-cloud-bigquery-jdbc</artifactId>
  <version>0.2.0</version><!-- {x-version-update:google-cloud-bigquery-jdbc:current} -->
  <packaging>jar</packaging>
  <name>BigQuery JDBC</name>
  <url>https://github.com/googleapis/java-bigquery-jdbc</url>
  <description>JDBC for BigQuery</description>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <github.global.server>github</github.global.server>
    <site.installationModule>google-cloud-bigquery-jdbc
    </site.installationModule>
  </properties>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.5.2</version>
        <configuration>
          <skip>${skipSurefire}</skip>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.8.13</version>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <configuration>
            <ignoredUsedUndeclaredDependencies>
                <ignoredUsedUndeclaredDependency>com.google.*:*</ignoredUsedUndeclaredDependency>
                <ignoredUsedUndeclaredDependency>org.apache.arrow:*</ignoredUsedUndeclaredDependency>
                <ignoredUsedUndeclaredDependency>org.apache.httpcomponents.*:*</ignoredUsedUndeclaredDependency>
                <ignoredUsedUndeclaredDependency>io.grpc:*</ignoredUsedUndeclaredDependency>
            </ignoredUsedUndeclaredDependencies>
        </configuration>
    </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.5.2</version> <!-- Use the latest version -->
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                  <shadedArtifactAttached>true</shadedArtifactAttached>
                  <shadedClassifierName>all</shadedClassifierName> <!-- Any name that makes sense -->
                  <createDependencyReducedPom>false</createDependencyReducedPom>
                  <archive>
                      <manifestEntries>
                          <Add-Opens>java.base/java.nio=ALL-UNNAMED</Add-Opens>
                      </manifestEntries>
                  </archive>
                  <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"/>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                      <resource>META-INF/io.netty.versions.properties</resource>
                    </transformer>
                  </transformers>
                  <relocations>
                    <relocation>
                      <pattern>com</pattern>
                      <shadedPattern>com.google.bqjdbc.shaded.com</shadedPattern>
                      <excludes>
                        <exclude>com.google.cloud.bigquery.*</exclude>
                        <exclude>com.google.cloud.bigquery.jdbc.*</exclude>
                      </excludes>
                    </relocation>
                    <relocation>
                      <pattern>org</pattern>
                      <shadedPattern>com.google.bqjdbc.shaded.org</shadedPattern>
                      <excludes>
                        <exclude>org.conscrypt.*</exclude>
                      </excludes>
                    </relocation>
                    <relocation>
                      <pattern>io</pattern>
                      <shadedPattern>com.google.bqjdbc.shaded.io</shadedPattern>
                    </relocation>
                  </relocations>
                  <filters>
                      <filter>
                          <artifact>*:*</artifact>
                          <excludes>
                              <exclude>META-INF/LICENSE*</exclude>
                              <exclude>META-INF/NOTICE*</exclude>
                              <exclude>META-INF/DEPENDENCIES</exclude>
                              <exclude>META-INF/proguard/*.pro</exclude>
                              <exclude>META-INF/maven/**</exclude>
                              <exclude>META-INF/*.MF</exclude>
                              <exclude>META-INF/*.SF</exclude>
                              <exclude>META-INF/*.DSA</exclude>
                              <exclude>META-INF/*.RSA</exclude>
                              <exclude>arrow-git.properties</exclude>
                          </excludes>
                      </filter>
                  </filters>
                </configuration>
              </execution>
            </executions>
          </plugin>
    </plugins>
  </build>

  <parent>
    <groupId>com.google.cloud</groupId>
    <artifactId>google-cloud-bigquery-parent</artifactId>
    <version>2.58.0</version><!-- {x-version-update:google-cloud-bigquery:current} -->
  </parent>
  <dependencies>
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud-bigquery</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud-bigquerystorage</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.http-client</groupId>
      <artifactId>google-http-client-apache-v5</artifactId>
      <exclusions> <!-- Exclusions are here for removing EOL vulnerability -->
        <exclusion>
          <groupId>org.apache.httpcomponents</groupId>
          <artifactId>httpcore</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.httpcomponents</groupId>
          <artifactId>httpclient</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- Transitive Dependencies  -->
    <dependency>
      <groupId>com.google.api</groupId>
      <artifactId>api-common</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.api</groupId>
      <artifactId>gax</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.api</groupId>
      <artifactId>gax-grpc</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.api.grpc</groupId>
      <artifactId>proto-google-cloud-bigquerystorage-v1</artifactId>
    </dependency>

    <dependency>
      <groupId>com.google.auth</groupId>
      <artifactId>google-auth-library-oauth2-http</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.auth</groupId>
      <artifactId>google-auth-library-credentials</artifactId>
    </dependency>

    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud-core</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud-core-http</artifactId>
    </dependency>

    <dependency>
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>jsr305</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</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.http-client</groupId>
      <artifactId>google-http-client</artifactId>
    </dependency>

    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-api</artifactId>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-core</artifactId>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-netty-shaded</artifactId>
    </dependency>


    <dependency>
      <groupId>org.apache.arrow</groupId>
      <artifactId>arrow-vector</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.arrow</groupId>
      <artifactId>arrow-memory-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents.client5</groupId>
      <artifactId>httpclient5</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents.core5</groupId>
      <artifactId>httpcore5</artifactId>
    </dependency>

    <!--  Test Dependencies  -->
    <dependency>
      <groupId>com.google.truth</groupId>
      <artifactId>truth</artifactId>
      <version>1.1.3</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.13.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>4.11.0</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>java17</id>
      <activation>
        <jdk>[17,)</jdk>
        <property>
          <!--
          In Java 8 unit tests where we run tests in Java 8 after building
          bytecode on Java 17, we don't want to add the argLine
          -->
          <name>!jvm</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <argLine>--add-opens=java.base/java.nio=org.apache.arrow.memory.core,ALL-UNNAMED</argLine>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- Profile used inside docker -->
    <profile>
      <id>docker</id>
      <activation>
        <property>
          <name>env.JDBC_DOCKER_ENV</name>
        </property>
      </activation>
      <build>
        <!-- Ensure it doesn't conflict with local build directories -->
        <directory>/mvn/test-target</directory>
      </build>
    </profile>
  </profiles>
</project>