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

  <parent>
    <groupId>com.spotify</groupId>
    <artifactId>foss-root</artifactId>
    <version>15</version>
  </parent>

  <groupId>com.spotify</groupId>
  <artifactId>dbeam-parent</artifactId>
  <version>0.10.13</version>
  <packaging>pom</packaging>
  <name>dbeam-parent</name>

  <organization>
    <name>Spotify AB</name>
    <url>http://www.spotify.com</url>
  </organization>

  <licenses>
    <license>
      <name>The Apache Software License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
      <comments>A business-friendly OSS license</comments>
    </license>
  </licenses>

  <developers>
    <developer>
      <id>labianchin</id>
      <name>Luis Bianchin</name>
      <email>labianchin@spotify.com</email>
      <organization>Spotify AB</organization>
      <organizationUrl>http://www.spotify.com</organizationUrl>
    </developer>
    <developer>
      <id>varjoranta</id>
      <name>Hannu Varjoranta</name>
      <email>varjo@spotify.com</email>
      <organization>Spotify AB</organization>
      <organizationUrl>http://www.spotify.com</organizationUrl>
    </developer>
    <developer>
      <id>honnix</id>
      <name>Hongxin Liang</name>
      <email>honnix@spotify.com</email>
      <organization>Spotify AB</organization>
      <organizationUrl>http://www.spotify.com</organizationUrl>
    </developer>
    <developer>
      <id>farzad</id>
      <name>Farzad Sedghi</name>
      <email>farzad@spotify.com</email>
      <organization>Spotify AB</organization>
      <organizationUrl>http://www.spotify.com</organizationUrl>
    </developer>
    <developer>
      <id>mfinkel</id>
      <name>Matt Finkel</name>
      <email>mfinkel@spotify.com</email>
      <organization>Spotify AB</organization>
      <organizationUrl>http://www.spotify.com</organizationUrl>
    </developer>
    <developer>
      <id>anishc</id>
      <name>Anish Chakraborty</name>
      <email>anishc@spotify.com</email>
      <organization>Spotify AB</organization>
      <organizationUrl>http://www.spotify.com</organizationUrl>
    </developer>
  </developers>

  <modules>
    <module>dbeam-core</module>
  </modules>

  <scm>
    <connection>scm:git:https://github.com/spotify/dbeam.git</connection>
    <developerConnection>scm:git:git@github.com:spotify/dbeam.git</developerConnection>
    <tag>v0.10.13</tag>
    <url>scm:https://github.com/spotify/dbeam/</url>
  </scm>

  <distributionManagement>
    <repository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
    <snapshotRepository>
      <id>github</id>
      <name>GitHub OWNER Apache Maven Packages</name>
      <url>https://maven.pkg.github.com/spotify/dbeam</url>
    </snapshotRepository>
  </distributionManagement>

  <properties>
    <maven.compiler.release>8</maven.compiler.release>
    <auto-value.version>1.10.1</auto-value.version>
    <avro.version>1.11.1</avro.version>
    <bouncycastle.version>1.70</bouncycastle.version>

    <beam.version>2.46.0</beam.version>
    <!--Ensure Beam SDK compatibility-->
    <!-- https://github.com/apache/beam/blob/release-2.46.0/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy#L449 -->
    <google-cloud-libaries-bom.version>26.8.0</google-cloud-libaries-bom.version>
    <google-http-clients.version>1.42.2</google-http-clients.version>
    <grpc.version>1.52.1</grpc.version>
    <guava.version>31.1-jre</guava.version>
    <hamcrest.version>2.2</hamcrest.version>
    <junit.version>4.13.2</junit.version>
    <jackson.version>2.14.2</jackson.version>
    <mysql.version>8.0.30</mysql.version>
    <netty.version>4.1.90.Final</netty.version>
    <postgresql.version>42.6.0</postgresql.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <protobuf.version>3.21.12</protobuf.version>
    <slf4j.version>1.7.36</slf4j.version>
    <socket-factory.version>1.10.0</socket-factory.version>
  </properties>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-bom</artifactId>
        <version>${netty.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>com.fasterxml.jackson</groupId>
        <artifactId>jackson-bom</artifactId>
        <version>${jackson.version}</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
      <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-bom</artifactId>
        <version>${grpc.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>com.google.cloud</groupId>
        <artifactId>libraries-bom</artifactId>
        <version>${google-cloud-libaries-bom.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcprov-jdk15on</artifactId>
        <version>${bouncycastle.version}</version>
      </dependency>
      <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcpkix-jdk15on</artifactId>
        <version>${bouncycastle.version}</version>
      </dependency>
      <dependency>
        <groupId>org.apache.beam</groupId>
        <artifactId>beam-sdks-java-bom</artifactId>
        <version>${beam.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>

      <!-- Logs -->
      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${slf4j.version}</version>
      </dependency>
      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-jdk14</artifactId>
        <version>${slf4j.version}</version>
        <scope>runtime</scope>
      </dependency>

      <!-- Runners -->
      <dependency>
        <groupId>org.apache.beam</groupId>
        <artifactId>beam-sdks-java-core</artifactId>
        <version>${beam.version}</version>
        <exclusions>
          <exclusion>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest</artifactId>
          </exclusion>
        </exclusions>
      </dependency>
      <dependency>
        <groupId>org.apache.beam</groupId>
        <artifactId>beam-runners-direct-java</artifactId>
        <version>${beam.version}</version>
        <exclusions>
          <exclusion>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest</artifactId>
          </exclusion>
        </exclusions>
      </dependency>
      <dependency>
        <groupId>org.apache.beam</groupId>
        <artifactId>beam-runners-google-cloud-dataflow-java</artifactId>
        <version>${beam.version}</version>
        <exclusions>
          <exclusion>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
          </exclusion>
          <exclusion>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest</artifactId>
          </exclusion>
          <exclusion>
            <groupId>com.google.api.grpc</groupId>
            <artifactId>grpc-google-cloud-pubsub-v1</artifactId>
          </exclusion>
          <exclusion>
            <groupId>com.google.api.grpc</groupId>
            <artifactId>proto-google-cloud-datastore-v1</artifactId>
          </exclusion>
          <exclusion>
            <groupId>com.google.api.grpc</groupId>
            <artifactId>proto-google-cloud-pubsublite-v1</artifactId>
          </exclusion>
          <exclusion>
            <groupId>com.google.api.grpc</groupId>
            <artifactId>grpc-google-cloud-pubsublite-v1</artifactId>
          </exclusion>
          <exclusion>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-spanner</artifactId>
          </exclusion>
          <exclusion>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-pubsub</artifactId>
          </exclusion>
          <exclusion>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-pubsublite</artifactId>
          </exclusion>
          <exclusion>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-bigquerystorage</artifactId>
          </exclusion>
          <exclusion>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-firestore</artifactId>
          </exclusion>
          <exclusion>
            <groupId>com.google.cloud.bigtable</groupId>
            <artifactId>bigtable-client-core</artifactId>
          </exclusion>
          <exclusion>
            <groupId>com.google.cloud.datastore</groupId>
            <artifactId>datastore-v1-proto-client</artifactId>
          </exclusion>
          <exclusion>
            <groupId>org.apache.avro</groupId>
            <artifactId>avro</artifactId>
          </exclusion>
          <exclusion>
            <groupId>org.apache.beam</groupId>
            <artifactId>beam-sdks-java-io-kafka</artifactId>
          </exclusion>
          <exclusion>
            <groupId>io.opencensus</groupId>
            <artifactId>opencensus-exporter-stats-stackdriver</artifactId>
          </exclusion>
        </exclusions>
      </dependency>
      <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>${guava.version}</version>
      </dependency>
      <dependency>
        <groupId>org.apache.avro</groupId>
        <artifactId>avro</artifactId>
        <version>${avro.version}</version>
      </dependency>
      <dependency>
        <groupId>com.github.luben</groupId>
        <artifactId>zstd-jni</artifactId>
        <version>1.5.4-2</version>
      </dependency>
      <dependency>
        <groupId>org.threeten</groupId>
        <artifactId>threetenbp</artifactId>
        <version>1.6.8</version>
      </dependency>
      <dependency>
        <groupId>com.google.auto.value</groupId>
        <artifactId>auto-value-annotations</artifactId>
        <version>${auto-value.version}</version>
      </dependency>
      <dependency>
        <groupId>com.google.auto.value</groupId>
        <artifactId>auto-value</artifactId>
        <version>${auto-value.version}</version>
        <scope>provided</scope>
      </dependency>
      <dependency>
        <groupId>com.google.errorprone</groupId>
        <artifactId>error_prone_annotations</artifactId>
        <version>2.18.0</version>
      </dependency>
      <dependency>
        <groupId>org.checkerframework</groupId>
        <artifactId>checker-qual</artifactId>
        <version>3.32.0</version>
      </dependency>
      <dependency>
        <groupId>org.checkerframework</groupId>
        <artifactId>checker-compat-qual</artifactId>
        <version>2.5.5</version>
      </dependency>
      <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpcore</artifactId>
        <version>4.4.16</version>
      </dependency>
      <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.14</version>
      </dependency>
      <dependency>
        <groupId>com.google.apis</groupId>
        <artifactId>google-api-services-cloudkms</artifactId>
        <version>v1-rev20230307-2.0.0</version>
      </dependency>

      <!-- DB Deps -->
      <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>${postgresql.version}</version>
      </dependency>
      <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>${mysql.version}</version>
      </dependency>
      <dependency>
        <groupId>com.google.cloud.sql</groupId>
        <artifactId>postgres-socket-factory</artifactId>
        <version>${socket-factory.version}</version>
      </dependency>
      <dependency>
        <groupId>com.google.cloud.sql</groupId>
        <artifactId>mysql-socket-factory</artifactId>
        <version>${socket-factory.version}</version>
      </dependency>

      <!-- Test Deps -->

      <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-core</artifactId>
        <version>${hamcrest.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-library</artifactId>
        <version>${hamcrest.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-core</artifactId>
        <version>5.2.0</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>2.1.214</version>
        <scope>test</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.google.auto.value</groupId>
      <artifactId>auto-value</artifactId>
    </dependency>
  </dependencies>

  <repositories>
    <repository>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <id>apache.snapshots</id>
      <name>Apache Development Snapshot Repository</name>
      <url>https://repository.apache.org/content/repositories/snapshots/</url>
    </repository>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>ossrh</id>
      <name>Sonatype OSS</name>
      <url>https://oss.sonatype.org/content/repositories/releases/</url>
    </repository>
  </repositories>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.11.0</version>
          <executions>
            <execution>
              <goals>
                <goal>compile</goal>
              </goals>
              <phase>compile</phase>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>3.0.0</version>
          <configuration>
            <tagNameFormat>v@{project.version}</tagNameFormat>
            <allowTimestampedSnapshots>true</allowTimestampedSnapshots>
            <autoVersionSubmodules>true</autoVersionSubmodules>
            <useReleaseProfile>false</useReleaseProfile>
            <releaseProfiles>release</releaseProfiles>
            <goals>deploy</goals>
          </configuration>
          <dependencies>
            <dependency>
              <groupId>org.apache.maven.scm</groupId>
              <artifactId>maven-scm-provider-gitexe</artifactId>
              <version>2.0.0</version>
            </dependency>
            <dependency>
              <groupId>org.apache.maven.scm</groupId>
              <artifactId>maven-scm-api</artifactId>
              <version>2.0.0</version>
            </dependency>
          </dependencies>
        </plugin>

        <plugin>
          <artifactId>maven-site-plugin</artifactId>
          <version>3.12.1</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.3.0</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>3.2.1</version>
          <executions>
            <execution>
              <id>attach-sources</id>
              <goals>
                <goal>jar</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-project-info-reports-plugin</artifactId>
          <version>3.4.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>3.0.0</version>
          <configuration>
            <reuseForks>true</reuseForks>
            <!--<forkCount>2</forkCount>-->
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-enforcer-plugin</artifactId>
          <version>3.1.0</version>
          <executions>
            <execution>
              <id>enforce</id>
              <goals>
                <goal>enforce</goal>
              </goals>
              <configuration>
                <rules>
                  <requireJavaVersion>
                    <version>[11,)</version>
                  </requireJavaVersion>
                  <requireMavenVersion>
                    <!-- Keep aligned with prerequisite section below. -->
                    <version>[3.3.9,)</version>
                  </requireMavenVersion>
                </rules>
              </configuration>
            </execution>
            <execution>
              <id>enforce-banned-dependencies</id>
              <goals>
                <goal>enforce</goal>
              </goals>
              <configuration>
                <rules>
                  <bannedDependencies>
                    <excludes>
                      <exclude>com.google.guava:guava-jdk5</exclude>
                      <exclude>com.google.protobuf:protobuf-lite</exclude>
                      <exclude>org.hamcrest:hamcrest-all</exclude>
                    </excludes>
                  </bannedDependencies>
                </rules>
                <fail>true</fail>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>

    </pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-enforcer-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-failsafe-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>3.2.1</version>
        <configuration>
          <includeTestSourceDirectory>true</includeTestSourceDirectory>
          <violationSeverity>warning</violationSeverity>
          <excludes>**\/AutoValue_*.java</excludes>

          <configLocation>google_checks.xml</configLocation>
          <consoleOutput>true</consoleOutput>
          <!-- Remove or switch to false to keep building even with checkstyle errors -->
          <failOnViolation>true</failOnViolation>
          <logViolationsToConsole>true</logViolationsToConsole>
          <suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
          <suppressionsFileExpression>checkstyle.suppressions.file</suppressionsFileExpression>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>com.puppycrawl.tools</groupId>
            <artifactId>checkstyle</artifactId>
            <version>10.9.3</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>release</id>
      <!-- Based on: https://central.sonatype.org/pages/apache-maven.html-->
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>3.0.1</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <goals>
                  <goal>sign</goal>
                </goals>
                <phase>verify</phase>
                <configuration>
                  <gpgArguments>
                    <arg>--batch</arg>
                    <arg>--pinentry-mode</arg>
                    <arg>loopback</arg>
                  </gpgArguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>3.2.1</version>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar-no-fork</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>3.5.0</version>
            <configuration>
              <source>8</source>
            </configuration>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <!--Using newer versions leads failure: https://issues.sonatype.org/browse/NEXUS-31301-->
            <version>1.6.8</version>
            <extensions>true</extensions>
            <configuration>
              <serverId>ossrh</serverId>
              <nexusUrl>https://oss.sonatype.org/</nexusUrl>
              <autoReleaseAfterClose>true</autoReleaseAfterClose>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>pack</id>
      <build>
        <plugins>
          <!--Based on: https://www.baeldung.com/executable-jar-with-maven-->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.4.1</version>
            <executions>
              <execution>
                <id>bundle-and-repackage</id>
                <goals>
                  <goal>shade</goal>
                </goals>
                <phase>package</phase>
                <configuration>
                  <dependencyReducedPomLocation>${basedir}/target/dependency-reduced-pom.xml</dependencyReducedPomLocation>
                  <artifactSet>
                    <includes>
                      <include>*:*</include>
                    </includes>
                  </artifactSet>
                  <filters>
                    <filter>
                      <artifact>*:*</artifact>
                      <excludes>
                        <exclude>META-INF/*.SF</exclude>
                        <exclude>META-INF/*.DSA</exclude>
                        <exclude>META-INF/*.RSA</exclude>
                      </excludes>
                    </filter>
                  </filters>
                  <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                      <mainClass>com.spotify.dbeam.jobs.JdbcAvroJob</mainClass>
                    </transformer>
                  </transformers>
                  <outputFile>${basedir}/target/${project.artifactId}-shaded.jar</outputFile>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>coverage</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.8.9</version>
            <configuration>
              <!--Configure to work on codecov-->
              <!--https://github.com/codecov/example-java/blob/master/pom.xml-->
              <excludes>
                <exclude>**/AutoValue_*.*</exclude>
              </excludes>
              <rules>
                <rule implementation="org.jacoco.maven.RuleConfiguration">
                  <element>BUNDLE</element>
                  <limits>
                    <limit implementation="org.jacoco.report.check.Limit">
                      <counter>INSTRUCTION</counter>
                      <value>COVEREDRATIO</value>
                      <minimum>0.60</minimum>
                    </limit>
                  </limits>
                </rule>
              </rules>
            </configuration>
            <executions>
              <execution>
                <id>pre-test</id>
                <goals>
                  <goal>prepare-agent</goal>
                </goals>
              </execution>
              <execution>
                <id>default-check</id>
                <goals>
                  <goal>check</goal>
                </goals>
              </execution>
              <execution>
                <id>post-unit-test</id>
                <goals>
                  <goal>report</goal>
                </goals>
                <phase>test</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
