<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.19.0</version><!-- {x-version-update:gapic-generator-java:current} -->
  <name>GAPIC Generator Java</name>
  <description>GAPIC generator Java</description>

  <properties>
    <checkstyle.skip>true</checkstyle.skip>
    <animal.sniffer.skip>true</animal.sniffer.skip>
    <clirr.skip>true</clirr.skip>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <!-- Should be in sync with repositories.bzl -->
    <googleapis.commit>44d6bef0ca6db8bba3fb324c8186e694bcc4829c</googleapis.commit>
    <auto-value.version>1.10.1</auto-value.version>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>

  <parent>
    <groupId>com.google.api</groupId>
    <artifactId>gapic-generator-java-pom-parent</artifactId>
    <version>2.19.0</version><!-- {x-version-update:gapic-generator-java:current} -->
    <relativePath>../gapic-generator-java-pom-parent</relativePath>
  </parent>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.google.api</groupId>
        <artifactId>gapic-generator-java-bom</artifactId>
        <version>2.19.0</version><!-- {x-version-update:gapic-generator-java:current} -->
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

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

    <!-- Skip gapic-generator-java when analyzing showcase test coverage on SonarCloud   -->
    <profile>
      <id>showcase-sonar-analysis</id>
      <activation>
        <property>
          <name>enableShowcaseTestCoverage</name>
        </property>
      </activation>
      <properties>
        <sonar.skip>true</sonar.skip>
      </properties>
    </profile>
  </profiles>

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

    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>flatten-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.11.0</version>
        <configuration>
          <source>8</source>
          <target>8</target>
          <annotationProcessorPaths>
            <path>
              <groupId>com.google.auto.value</groupId>
              <artifactId>auto-value</artifactId>
              <version>${auto-value.version}</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>target/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>target/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>target/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>target/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>target/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>target/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>target/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>target/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>
            <configuration>
              <protoSourceRoot>src/main/proto</protoSourceRoot>
            </configuration>
          </execution>
          <execution>
            <id>compile-downloaded-protos</id>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <protoSourceRoot>target/generated-sources/proto</protoSourceRoot>
              <clearOutputDirectory>false</clearOutputDirectory>
            </configuration>
          </execution>
          <execution>
            <id>compile-test-protos</id>
            <goals>
              <goal>test-compile</goal>
            </goals>
            <configuration>
              <protoTestSourceRoot>src/test/proto</protoTestSourceRoot>
              <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>target/generated-test-sources/proto</protoTestSourceRoot>
              <clearOutputDirectory>false</clearOutputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>test-jar</goal>
            </goals>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.0.0</version>
        <configuration>
          <additionalClasspathElements>
            <additionalClasspathElement>
              target/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>

  <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>
      <!-- import the test code, https://maven.apache.org/plugins/maven-jar-plugin/examples/create-test-jar.html -->
      <type>test-jar</type>
      <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>
      <!-- import the test code, https://maven.apache.org/plugins/maven-jar-plugin/examples/create-test-jar.html -->
      <type>test-jar</type>
      <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>
      <!-- import the test code, https://maven.apache.org/plugins/maven-jar-plugin/examples/create-test-jar.html -->
      <type>test-jar</type>
      <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>
    </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>2.0</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.18.0</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>${javax.annotation-api.version}</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>
</project>
