<?xml version="1.0" encoding="UTF-8"?>
<!--
 Copyright 2021 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: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>
    <groupId>com.google.cloud.sql</groupId>
    <artifactId>jdbc-socket-factory-parent</artifactId>
    <version>1.23.1</version><!-- {x-version-update:jdbc-socket-factory-parent:current} -->
    <relativePath>../../pom.xml</relativePath>
  </parent>
  <artifactId>postgres-socket-factory</artifactId>
  <version>1.23.1</version><!-- {x-version-update:postgres-socket-factory:current} -->
  <packaging>jar</packaging>

  <name>Cloud SQL Postgres Socket Factory</name>
  <description>
    Socket factory for the Postgres JDBC driver that allows a user with the appropriate permissions
    to connect to a Cloud SQL database without having to deal with IP allowlisting or SSL
    certificates manually.
  </description>

  <properties>
    <assembly.skipAssembly>false</assembly.skipAssembly>
  </properties>

  <dependencies>
    <dependency>
      <groupId>com.google.cloud.sql</groupId>
      <artifactId>jdbc-socket-factory-core</artifactId>
      <version>${project.parent.version}</version>
    </dependency>
    <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
      <version>42.7.5</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.truth</groupId>
      <artifactId>truth</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.zaxxer</groupId>
      <artifactId>HikariCP</artifactId>
      <scope>test</scope>
    </dependency>
    <!-- Logging -->
    <dependency> 
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>
    <dependency> 
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>jar-with-driver-and-dependencies</id>
      <dependencies>
        <dependency>
          <groupId>org.postgresql</groupId>
          <artifactId>postgresql</artifactId>
          <version>42.7.5</version>
        </dependency>
      </dependencies>
    </profile>
    <!-- Upgrading to v0.9.12 of the native maven plugin leaves 
        provided scope dependencies out of the classpath, so adding these
        drivers back in for the native profile is a workaround.
    -->
    <profile>
      <id>native</id>
      <dependencies>
        <dependency>
          <groupId>org.postgresql</groupId>
          <artifactId>postgresql</artifactId>
          <version>42.7.5</version>
        </dependency>
      </dependencies>
    </profile>

    <profile>
      <id>google-conscript</id>
      <dependencies>
        <dependency>
          <groupId>org.conscrypt</groupId>
          <artifactId>conscrypt-openjdk-uber</artifactId>
          <version>2.5.2</version>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.5.2</version>
            <executions>
              <execution>
                <phase>integration-test</phase>
                <goals>
                  <goal>test</goal>
                </goals>
                <configuration>
                  <!-- double-equals means override the JRE default properties, don't append -->
                  <argLine>-Djava.security.properties==src/test/resources/conscrypt-security.properties</argLine>
                  <classpathDependencyExcludes>
                    <classpathDependencyExclude>org.bouncycastle:bcpkix-jdk15on</classpathDependencyExclude>
                    <classpathDependencyExclude>org.bouncycastle:bcprov-jdk15on</classpathDependencyExclude>
                    <classpathDependencyExclude>org.bouncycastle:bcutil-jdk15on</classpathDependencyExclude>
                  </classpathDependencyExcludes>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>


  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <configuration>
          <usedDependencies>
            <!-- This dependency is not used at compile-time. -->
            <dependency>ch.qos.logback:logback-classic</dependency>
          </usedDependencies>
        </configuration>
      </plugin>
    </plugins>
  </build>

</project>
