<?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.spotify</groupId>
    <artifactId>dbeam-parent</artifactId>
    <version>0.10.5</version>
    <packaging>pom</packaging>
    <name>dbeam-parent</name>

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

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

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

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

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

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

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

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>

        <beam.version>2.35.0</beam.version>
        <!--Ensure Beam SDK compatibility-->
        <!-- https://github.com/apache/beam/blob/release-2.35.0/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy#L536 -->
        <google-cloud-libaries-bom.version>24.0.0</google-cloud-libaries-bom.version>
        <grpc.version>1.41.1</grpc.version>
        <guava.version>31.0.1-jre</guava.version>
        <netty.version>4.1.72.Final</netty.version>
        <protobuf.version>3.18.1</protobuf.version>
        <avro.version>1.10.2</avro.version>
        <slf4j.version>1.7.32</slf4j.version>
        <auto-value.version>1.8.2</auto-value.version>
        <google-clients.version>1.32.2</google-clients.version>
        <socket-factory.version>1.2.2</socket-factory.version>
        <postgresql.version>42.3.1</postgresql.version>
        <mysql.version>8.0.27</mysql.version>
        <junit.version>4.13.2</junit.version>
        <hamcrest.version>2.2</hamcrest.version>
    </properties>

    <modules>
        <module>dbeam-core</module>
    </modules>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.grpc</groupId>
                <artifactId>grpc-bom</artifactId>
                <version>${grpc.version}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
            <dependency>
                <groupId>org.apache.beam</groupId>
                <artifactId>beam-sdks-java-bom</artifactId>
                <version>${beam.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>

            <!-- 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-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-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>
                </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.0-4</version>
            </dependency>
            <dependency>
                <groupId>org.threeten</groupId>
                <artifactId>threetenbp</artifactId>
                <version>1.5.1</version>
            </dependency>
            <dependency>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
                <version>1.15</version>
            </dependency>
            <dependency>
                <groupId>org.osgi</groupId>
                <artifactId>org.osgi.core</artifactId>
                <version>6.0.0</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>io.netty</groupId>
                <artifactId>netty-handler</artifactId>
                <version>${netty.version}</version>
            </dependency>
            <dependency>
                <groupId>com.google.errorprone</groupId>
                <artifactId>error_prone_annotations</artifactId>
                <version>2.10.0</version>
            </dependency>
            <dependency>
                <groupId>org.checkerframework</groupId>
                <artifactId>checker-qual</artifactId>
                <version>3.12.0</version>
            </dependency>
            <dependency>
                <groupId>com.google.api-client</groupId>
                <artifactId>google-api-client</artifactId>
                <version>${google-clients.version}</version>
            </dependency>
            <dependency>
                <groupId>com.google.api.grpc</groupId>
                <artifactId>proto-google-iam-v1</artifactId>
                <version>1.1.7</version>
            </dependency>
            <dependency>
                <groupId>com.google.apis</groupId>
                <artifactId>google-api-services-cloudkms</artifactId>
                <version>v1-rev20211130-1.32.1</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>3.12.4</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
                <version>1.4.200</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.google.auto.value</groupId>
            <artifactId>auto-value</artifactId>
        </dependency>
    </dependencies>

    <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>
                  <phase>verify</phase>
                  <goals>
                    <goal>sign</goal>
                  </goals>
                  <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.3.1</version>
              <executions>
                <execution>
                  <id>attach-javadocs</id>
                  <goals>
                    <goal>jar</goal>
                  </goals>
                </execution>
              </executions>
              <configuration>
                  <source>8</source>
              </configuration>
            </plugin>
            <plugin>
              <groupId>org.sonatype.plugins</groupId>
              <artifactId>nexus-staging-maven-plugin</artifactId>
              <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.2.4</version>
              <executions>
                <execution>
                  <id>bundle-and-repackage</id>
                  <phase>package</phase>
                  <goals>
                    <goal>shade</goal>
                  </goals>
                  <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.7</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>
                  <phase>test</phase>
                  <goals>
                    <goal>report</goal>
                  </goals>
                </execution>
              </executions>
            </plugin>
          </plugins>
        </build>
      </profile>
    </profiles>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.1</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>compile</phase>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>2.5.3</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>1.12.0</version>
                        </dependency>
                        <dependency>
                            <groupId>org.apache.maven.scm</groupId>
                            <artifactId>maven-scm-api</artifactId>
                            <version>1.12.0</version>
                        </dependency>
                    </dependencies>
                </plugin>

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

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.2.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.1.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.0.0-M5</version>
                    <configuration>
                        <reuseForks>true</reuseForks>
                        <!--<forkCount>2</forkCount>-->
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>3.0.0</version>
                    <executions>
                        <execution>
                            <id>enforce</id>
                            <goals>
                                <goal>enforce</goal>
                            </goals>
                            <configuration>
                                <rules>
                                    <requireJavaVersion>
                                        <version>[1.8,)</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.1.2</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>9.2</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-release-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
