<!--
 Copyright 2020 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">
  <properties>
    <java.version>1.8</java.version>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <skipITs>true</skipITs>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

    <excludedTests>com.google.cloud.spanner.pgadapter.IntegrationTest,com.google.cloud.spanner.pgadapter.golang.GolangTest</excludedTests>
  </properties>

  <modelVersion>4.0.0</modelVersion>
  <artifactId>google-cloud-spanner-pgadapter</artifactId>
  <version>0.3.0</version><!-- {x-version-update:google-cloud-spanner-pgadapter:current} -->
  <name>Google Cloud Spanner PostgreSQL Adapter</name>
  <packaging>jar</packaging>
  <description>
    The PGAdapter server implements the PostgreSQL wire-protocol, but sends all received statements
    to a Cloud Spanner database instead of a PostgreSQL database. The Cloud Spanner database must
    have been created using the PostgreSQL dialect. See https://cloud.google.com/spanner/docs/quickstart-console#postgresql
    for more information on how to create PostgreSQL dialect databases on Cloud Spanner.
  </description>
  <parent>
    <groupId>com.google.cloud</groupId>
    <artifactId>google-cloud-shared-config</artifactId>
    <version>1.2.7</version>
  </parent>
  <scm>
    <connection>scm:git:git@github.com:GoogleCloudPlatform/pgadapter.git</connection>
    <developerConnection>scm:git:git@github.com:GoogleCloudPlatform/pgadapter.git</developerConnection>
    <url>https://github.com/GoogleCloudPlatform/pgadapter</url>
    <tag>HEAD</tag>
  </scm>
  <issueManagement>
    <url>https://github.com/GoogleCloudPlatform/pgadapter/issues</url>
    <system>GitHub Issues</system>
  </issueManagement>
  <licenses>
    <license>
      <name>Apache-2.0</name>
      <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>

  <dependencies>
    <dependency>
      <groupId>com.googlecode.json-simple</groupId>
      <artifactId>json-simple</artifactId>
      <version>1.1.1</version>
    </dependency>
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud-spanner</artifactId>
      <version>6.21.0</version>
    </dependency>
    <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
      <version>42.3.1</version>
    </dependency>
    <dependency>
      <groupId>commons-cli</groupId>
      <artifactId>commons-cli</artifactId>
      <version>1.4</version>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-csv</artifactId>
      <version>1.9.0</version>
    </dependency>
    <dependency>
      <groupId>org.json</groupId>
      <artifactId>json</artifactId>
      <version>20210307</version>
    </dependency>
    <!-- Test dependencies -->
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud-spanner</artifactId>
      <version>6.21.0</version>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.api</groupId>
      <artifactId>gax-grpc</artifactId>
      <version>2.12.2</version>
      <classifier>testlib</classifier>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>net.java.dev.jna</groupId>
      <artifactId>jna</artifactId>
      <version>5.10.0</version>
    </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.3.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>shade</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.2.1</version>
            <executions>
              <execution>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                  <finalName>pgadapter</finalName>
                  <filters>
                    <filter>
                      <artifact>*:*</artifact>
                      <!-- We need to exclude the signatures for any signed jars otherwise
                      we get an exception. -->
                      <excludes>
                        <exclude>META-INF/*.SF</exclude>
                        <exclude>META-INF/*.DSA</exclude>
                        <exclude>META-INF/*.RSA</exclude>
                      </excludes>
                    </filter>
                  </filters>
                  <createSourcesJar>true</createSourcesJar>
                  <shadeSourcesContent>true</shadeSourcesContent>
                  <shadedArtifactAttached>false</shadedArtifactAttached>
                  <createDependencyReducedPom>false</createDependencyReducedPom>
                  <artifactSet>
                    <includes>
                      <include>*:*</include>
                    </includes>
                    <excludes>
                      <exclude>java:*</exclude>
                      <exclude>junit:*</exclude>
                    </excludes>
                  </artifactSet>
                  <transformers>
                    <transformer
                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                      <mainClass>com.google.cloud.spanner.pgadapter.Server
                      </mainClass>
                    </transformer>
                    <transformer
                        implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
                      <resource>META-INF/services</resource>
                      <file>io.grpc.LoadBalancerProvider</file>
                    </transformer>
                  </transformers>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>test-all</id>
      <properties>
        <excludedTests>com.google.cloud.spanner.pgadapter.IntegrationTest</excludedTests>
      </properties>
    </profile>
  </profiles>

  <build>
    <testResources>
      <testResource>
        <directory>${project.basedir}/src/test/resources</directory>
      </testResource>
      <testResource>
        <directory>${project.basedir}/src/main/resources</directory>
      </testResource>
    </testResources>
    <plugins>
      <plugin>
        <groupId>com.coveo</groupId>
        <artifactId>fmt-maven-plugin</artifactId>
        <version>2.5.1</version>
        <executions>
          <execution>
            <goals>
              <goal>format</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.0.0-M5</version>
        <configuration>
          <excludedGroups>${excludedTests}</excludedGroups>
          <reportNameSuffix>sponge_log</reportNameSuffix>
          <systemProperties>
            <property>
              <name>java.util.logging.config.file</name>
              <value>src/test/resources/logging.properties</value>
            </property>
          </systemProperties>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.8.7</version>
        <executions>
          <execution>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <execution>
            <id>report</id>
            <phase>test</phase>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>3.0.0-M3</version>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <skipITs>${skipITs}</skipITs>
        </configuration>
      </plugin>
    </plugins>
    <extensions>
      <extension>
        <groupId>com.google.cloud.artifactregistry</groupId>
        <artifactId>artifactregistry-maven-wagon</artifactId>
        <version>2.1.1</version>
      </extension>
    </extensions>
  </build>
</project>
