<?xml version="1.0" encoding="UTF-8"?>
<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.api</groupId>
  <artifactId>gapic-generator-java</artifactId>
  <version>2.12.0</version><!-- {x-version-update:gapic-generator-java:current} -->

  <parent>
    <groupId>com.google.cloud</groupId>
    <artifactId>google-cloud-shared-config</artifactId>
    <version>1.5.5</version>
  </parent>

  <properties>
    <checkstyle.skip>true</checkstyle.skip>
    <animal.sniffer.skip>true</animal.sniffer.skip>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <!-- Should be in sync with repositories.bzl -->
    <googleapis.commit>44d6bef0ca6db8bba3fb324c8186e694bcc4829c</googleapis.commit>
    <gax.version>2.20.1</gax.version>
    <grpc.version>1.51.0</grpc.version>
    <protobuf.version>3.21.10</protobuf.version>
    <auto-value.version>1.10.1</auto-value.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.google.api</groupId>
        <artifactId>gax-bom</artifactId>
        <version>${gax.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-bom</artifactId>
        <version>${grpc.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>31.1-jre</version>
    </dependency>
    <dependency>
      <groupId>com.google.api</groupId>
      <artifactId>gax</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.api</groupId>
      <artifactId>gax</artifactId>
      <classifier>testlib</classifier>
    </dependency>
    <dependency>
      <groupId>com.google.api</groupId>
      <artifactId>gax-grpc</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.api</groupId>
      <artifactId>gax-grpc</artifactId>
      <classifier>testlib</classifier>
    </dependency>
    <dependency>
      <groupId>com.google.api</groupId>
      <artifactId>gax-httpjson</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.api</groupId>
      <artifactId>gax-httpjson</artifactId>
      <classifier>testlib</classifier>
    </dependency>
    <dependency>
      <groupId>com.google.auto.value</groupId>
      <artifactId>auto-value-annotations</artifactId>
      <version>${auto-value.version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.protobuf</groupId>
      <artifactId>protobuf-java-util</artifactId>
      <version>${protobuf.version}</version>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-stub</artifactId>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-protobuf</artifactId>
    </dependency>
    <dependency>
      <groupId>org.yaml</groupId>
      <artifactId>snakeyaml</artifactId>
      <version>1.33</version>
    </dependency>
    <dependency>
      <groupId>com.google.googlejavaformat</groupId>
      <artifactId>google-java-format</artifactId>
      <version>1.7</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.13.2</version>
    </dependency>
    <dependency>
      <groupId>com.google.errorprone</groupId>
      <artifactId>error_prone_annotations</artifactId>
      <version>2.16</version>
    </dependency>

    <!--
      TODO: remove when dropping Java 8.
      https://github.com/googleapis/gapic-generator-java/issues/888
    -->
    <dependency>
      <groupId>javax.annotation</groupId>
      <artifactId>javax.annotation-api</artifactId>
      <version>1.3.2</version>
    </dependency>

    <dependency>
      <groupId>com.google.truth</groupId>
      <artifactId>truth</artifactId>
      <version>1.1.3</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.github.java-diff-utils</groupId>
      <artifactId>java-diff-utils</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <extensions>
      <extension>
        <groupId>kr.motd.maven</groupId>
        <artifactId>os-maven-plugin</artifactId>
        <version>1.7.1</version>
      </extension>
    </extensions>

    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.10.1</version>
        <configuration>
          <source>8</source>
          <target>8</target>
          <annotationProcessorPaths>
            <path>
              <groupId>com.google.auto.value</groupId>
              <artifactId>auto-value</artifactId>
              <version>1.10.1</version>
            </path>
          </annotationProcessorPaths>
        </configuration>
      </plugin>

      <plugin>
        <groupId>com.coveo</groupId>
        <artifactId>fmt-maven-plugin</artifactId>
        <version>2.9.1</version>
      </plugin>

      <plugin>
        <groupId>com.googlecode.maven-download-plugin</groupId>
        <artifactId>download-maven-plugin</artifactId>
        <version>1.6.8</version>
        <executions>
          <execution>
            <id>download-metadata-proto</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>wget</goal>
            </goals>
            <configuration>
              <url>https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/gapic/metadata/gapic_metadata.proto</url>
              <outputDirectory>${project.build.directory}/generated-sources/proto/</outputDirectory>
            </configuration>
          </execution>
          <execution>
            <id>download-common-resources-proto</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>wget</goal>
            </goals>
            <configuration>
              <url>https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/google/cloud/common_resources.proto</url>
              <outputDirectory>${project.build.directory}/generated-test-sources/proto/</outputDirectory>
            </configuration>
          </execution>
          <execution>
            <id>download-pubsub-proto</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>wget</goal>
            </goals>
            <configuration>
              <url>https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/google/pubsub/v1/pubsub.proto</url>
              <outputDirectory>${project.build.directory}/generated-test-sources/proto/</outputDirectory>
            </configuration>
          </execution>
          <execution>
            <id>download-schema-proto</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>wget</goal>
            </goals>
            <configuration>
              <url>https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/google/pubsub/v1/schema.proto</url>
              <outputDirectory>${project.build.directory}/generated-test-sources/proto/google/pubsub/v1/</outputDirectory>
            </configuration>
          </execution>
          <execution>
            <id>download-logging-proto</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>wget</goal>
            </goals>
            <configuration>
              <url>https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/google/logging/v2/logging.proto</url>
              <outputDirectory>${project.build.directory}/generated-test-sources/proto/</outputDirectory>
            </configuration>
          </execution>
          <execution>
            <id>download-log-entry-proto</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>wget</goal>
            </goals>
            <configuration>
              <url>https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/google/logging/v2/log_entry.proto</url>
              <outputDirectory>${project.build.directory}/generated-test-sources/proto/google/logging/v2/</outputDirectory>
            </configuration>
          </execution>
          <execution>
            <id>download-logging-config-proto</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>wget</goal>
            </goals>
            <configuration>
              <url>https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/google/logging/v2/logging_config.proto</url>
              <outputDirectory>${project.build.directory}/generated-test-sources/proto/google/logging/v2/</outputDirectory>
            </configuration>
          </execution>
          <execution>
            <id>download-logging-metrics-proto</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>wget</goal>
            </goals>
            <configuration>
              <url>https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/google/logging/v2/logging_metrics.proto</url>
              <outputDirectory>${project.build.directory}/generated-test-sources/proto/google/logging/v2/</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.xolstice.maven.plugins</groupId>
        <artifactId>protobuf-maven-plugin</artifactId>
        <version>0.6.1</version>
        <configuration>
          <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
        </configuration>
        <executions>
          <execution>
            <id>compile-protos</id>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
          <execution>
            <id>compile-downloaded-protos</id>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <protoSourceRoot>${project.build.directory}/generated-sources/proto/</protoSourceRoot>
              <clearOutputDirectory>false</clearOutputDirectory>
            </configuration>
          </execution>
          <execution>
            <id>compile-test-protos</id>
            <goals>
              <goal>test-compile</goal>
            </goals>
            <configuration>
              <writeDescriptorSet>true</writeDescriptorSet>
              <includeSourceInfoInDescriptorSet>true</includeSourceInfoInDescriptorSet>
              <includeDependenciesInDescriptorSet>true</includeDependenciesInDescriptorSet>
              <descriptorSetFileName>test-proto.descriptorset</descriptorSetFileName>
            </configuration>
          </execution>
          <execution>
            <id>compile-downloaded-test-protos</id>
            <goals>
              <goal>test-compile</goal>
            </goals>
            <configuration>
              <protoTestSourceRoot>${project.build.directory}/generated-test-sources/proto/</protoTestSourceRoot>
              <clearOutputDirectory>false</clearOutputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.0.0-M7</version>
        <configuration>
          <additionalClasspathElements>
            <additionalClasspathElement>${project.build.directory}/generated-test-resources/protobuf/descriptor-sets/</additionalClasspathElement>
          </additionalClasspathElements>
        </configuration>
      </plugin>

      <!-- Code coverage for SonarCloud -->
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.8.8</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-shade-plugin</artifactId>
        <version>3.4.1</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <createDependencyReducedPom>false</createDependencyReducedPom>
              <filters>
                <filter>
                  <artifact>*:*</artifact>
                  <excludes>
                    <exclude>META-INF/*.SF</exclude>
                    <exclude>META-INF/*.DSA</exclude>
                    <exclude>META-INF/*.RSA</exclude>
                  </excludes>
                </filter>
              </filters>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  
  <profiles>
    <profile>
      <!-- profile for nexus-staging:release invocation -->
      <id>release-staging-repository</id>
      <activation>
        <property>
          <!-- The root project not using nexus-staging-maven-plugin when signing -->
          <name>!gpg.executable</name>
        </property>
      </activation>
      <distributionManagement>
        <snapshotRepository>
          <id>sonatype-nexus-snapshots</id>
          <url>https://google.oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
          <id>sonatype-nexus-staging</id>
          <url>https://google.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
      </distributionManagement>
      <build>
        <plugins>
          <plugin>
            <!-- The root project runs nexus-staging:release task -->
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <version>1.6.13</version>
            <extensions>true</extensions>
            <configuration>
              <serverId>sonatype-nexus-staging</serverId>
              <nexusUrl>https://google.oss.sonatype.org/</nexusUrl>
              <autoReleaseAfterClose>false</autoReleaseAfterClose>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
