<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <name>Spotify Root</name>
  <url>https://github.com/spotify/foss-root</url>
  <description>
    The Spotify Root project helps establish consistent Maven conventions by being the parent POM
    for other participating projects.
  </description>

  <groupId>com.spotify</groupId>
  <artifactId>foss-root</artifactId>
  <version>18</version>
  <packaging>pom</packaging>

  <properties>
    <java.version>1.8</java.version>
    <maven.compiler.source>${java.version}</maven.compiler.source>
    <maven.compiler.target>${java.version}</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <maven-test-plugins.version>3.1.2</maven-test-plugins.version>
    <unitTests.failIfNoTests>true</unitTests.failIfNoTests>
    <integrationTests.failIfNoTests>false</integrationTests.failIfNoTests>
  </properties>

  <scm>
    <url>https://github.com/spotify/foss-root</url>
    <connection>scm:git:git@github.com:spotify/foss-root.git</connection>
    <developerConnection>scm:git:git@github.com:spotify/foss-root.git</developerConnection>
    <tag>v18</tag>
  </scm>

  <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>
    </license>
  </licenses>

  <developers>
    <developer>
      <id>rouzwawi</id>
      <email>rouz@spotify.com</email>
      <name>Rouzbeh Delavari</name>
    </developer>
  </developers>

  <distributionManagement>
    <snapshotRepository>
      <id>central</id>
      <url>https://central.sonatype.com/repository/maven-snapshots/</url>
    </snapshotRepository>
    <repository>
      <id>central</id>
      <url>https://central.sonatype.com/repository/maven-releases/</url>
    </repository>
  </distributionManagement>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>license-maven-plugin</artifactId>
      </plugin>
    </plugins>

    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.1</version>
          <configuration>
            <showWarnings>true</showWarnings>
            <compilerArgs>
              <compilerArg>-Xlint:all</compilerArg>
            </compilerArgs>
          </configuration>
        </plugin>

        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.0.2</version>
          <configuration>
            <archive>
              <manifest>
                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
              </manifest>
            </archive>
          </configuration>
        </plugin>

        <plugin>
          <artifactId>maven-enforcer-plugin</artifactId>
          <version>3.3.0</version>
          <executions>
            <execution>
              <id>enforce</id>
              <configuration>
                <rules>
                  <requireMavenVersion>
                    <version>[3.5.4,)</version>
                  </requireMavenVersion>
                  <requireUpperBoundDeps />
                </rules>
              </configuration>
              <goals>
                <goal>enforce</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <version>3.1.1</version>
          <dependencies>
            <dependency>
              <groupId>com.spotify.checkstyle</groupId>
              <artifactId>spotify-checkstyle-config</artifactId>
              <version>1.0.11</version>
            </dependency>
          </dependencies>
          <configuration>
            <configLocation>spotify_checks.xml</configLocation>
            <consoleOutput>true</consoleOutput>
            <!-- Remove or switch to false to keep building even with checkstyle errors -->
            <failOnViolation>true</failOnViolation>
            <logViolationsToConsole>true</logViolationsToConsole>
            <!-- change to 'warning' to be more strict about following checkstyle conventions -->
            <violationSeverity>error</violationSeverity>
          </configuration>
          <executions>
            <execution>
              <id>validate</id>
              <phase>validate</phase>
              <goals>
                <goal>check</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>license-maven-plugin</artifactId>
          <version>1.20</version>
          <configuration>
            <addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
            <licenseName>apache_v2</licenseName>
            <organizationName>Spotify AB</organizationName>
            <inceptionYear>2016</inceptionYear>
            <encoding>UTF-8</encoding>
            <failOnMissingHeader>true</failOnMissingHeader>
            <failOnNotUptodateHeader>true</failOnNotUptodateHeader>
            <processStartTag>-\-\-</processStartTag>
            <processEndTag>-/-/-</processEndTag>
            <emptyLineAfterHeader>true</emptyLineAfterHeader>
            <roots>
              <root>src/main/java</root>
              <root>src/test/java</root>
            </roots>
            <sectionDelimiter>--</sectionDelimiter>
            <trimHeaderLine>true</trimHeaderLine>
          </configuration>
          <executions>
            <execution>
              <id>check-file-header</id>
              <goals>
                <goal>check-file-header</goal>
              </goals>
              <phase>process-sources</phase>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>3.0.1</version>
          <configuration>
            <tagNameFormat>v@{project.version}</tagNameFormat>
            <allowTimestampedSnapshots>true</allowTimestampedSnapshots>
            <releaseProfiles>release</releaseProfiles>
          </configuration>
          <dependencies>
            <dependency>
              <groupId>org.apache.maven.scm</groupId>
              <artifactId>maven-scm-provider-gitexe</artifactId>
              <version>2.0.1</version>
            </dependency>
          </dependencies>
        </plugin>
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>0.8.10</version>
          <executions>
            <execution>
              <id>report</id>
              <goals>
                <goal>prepare-agent</goal>
                <goal>report</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-changelog-plugin</artifactId>
          <version>2.3</version>
        </plugin>
        <plugin>
          <artifactId>maven-project-info-reports-plugin</artifactId>
          <version>3.4.5</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-report-plugin</artifactId>
          <version>3.1.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>3.5.0</version>
          <configuration>
            <failOnError>false</failOnError>
            <additionalparam>-Xdoclint:none</additionalparam>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-source-plugin</artifactId>
          <version>3.3.0</version>
        </plugin>
        <plugin>
          <groupId>org.sonatype.central</groupId>
          <artifactId>central-publishing-maven-plugin</artifactId>
          <version>0.8.0</version>
          <extensions>true</extensions>
          <configuration>
            <publishingServerId>central</publishingServerId>
            <autoPublish>true</autoPublish>
            <waitUntil>published</waitUntil>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-gpg-plugin</artifactId>
          <version>3.1.0</version>
          <executions>
            <execution>
              <id>sign-artifacts</id>
              <goals>
                <goal>sign</goal>
              </goals>
              <phase>verify</phase>
              <configuration>
                <gpgArguments>
                  <arg>--pinentry-mode</arg>
                  <arg>loopback</arg>
                </gpgArguments>
              </configuration>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>3.1.1</version>
        </plugin>

        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>findbugs-maven-plugin</artifactId>
          <version>3.0.5</version>
          <executions>
            <execution>
              <goals>
                <goal>check</goal>
              </goals>
              <phase>pre-integration-test</phase>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <groupId>com.coveo</groupId>
          <artifactId>fmt-maven-plugin</artifactId>
          <!-- 2.9.1 is the last version that can run on Java 8 -->
          <version>2.9.1</version>
          <executions>
            <execution>
              <goals>
                <goal>format</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${maven-test-plugins.version}</version>
          <dependencies>
            <dependency>
              <groupId>me.fabriciorby</groupId>
              <artifactId>maven-surefire-junit5-tree-reporter</artifactId>
              <version>1.2.1</version>
            </dependency>
          </dependencies>
          <configuration>
            <includes>
              <include>**/*Test.java</include>
              <include>**/*Tests.java</include>
            </includes>
            <excludes>
              <exclude>**/*IT.java</exclude>
              <exclude>**/integrationtests/*.java</exclude>
              <exclude>**/it/**/*.java</exclude>
            </excludes>
            <testFailureIgnore>false</testFailureIgnore>
            <failIfNoTests>${unitTests.failIfNoTests}</failIfNoTests>
            <trimStackTrace>false</trimStackTrace>
            <systemPropertyVariables>
              <spotify.test.type>unit</spotify.test.type>
              <spotify.target.dir>${project.build.directory}</spotify.target.dir>
            </systemPropertyVariables>
            <!--
            For tree reporter in console:
            https://github.com/fabriciorby/maven-surefire-junit5-tree-reporter
            Full reports are still written in the `target/surefire-reports` folder
            -->
            <reportFormat>plain</reportFormat>
            <statelessTestsetInfoReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoTreeReporterUnicode">
              <printStacktraceOnError>true</printStacktraceOnError>
              <printStacktraceOnFailure>true</printStacktraceOnFailure>
              <printStdoutOnError>true</printStdoutOnError>
              <printStdoutOnFailure>true</printStdoutOnFailure>
              <printStdoutOnSuccess>false</printStdoutOnSuccess>
              <printStderrOnError>true</printStderrOnError>
              <printStderrOnFailure>true</printStderrOnFailure>
              <printStderrOnSuccess>false</printStderrOnSuccess>
            </statelessTestsetInfoReporter>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>${maven-test-plugins.version}</version>
          <dependencies>
            <dependency>
              <groupId>me.fabriciorby</groupId>
              <artifactId>maven-surefire-junit5-tree-reporter</artifactId>
              <version>1.2.1</version>
            </dependency>
          </dependencies>
          <configuration>
            <trimStackTrace>false</trimStackTrace>
            <failIfNoTests>${integrationTests.failIfNoTests}</failIfNoTests>
            <!--
            For tree reporter in console:
            https://github.com/fabriciorby/maven-surefire-junit5-tree-reporter
            Full reports are still written in the `target/surefire-reports` folder
            -->
            <reportFormat>plain</reportFormat>
            <statelessTestsetInfoReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoTreeReporterUnicode">
              <printStacktraceOnError>true</printStacktraceOnError>
              <printStacktraceOnFailure>true</printStacktraceOnFailure>
              <printStdoutOnError>true</printStdoutOnError>
              <printStdoutOnFailure>true</printStdoutOnFailure>
              <printStdoutOnSuccess>false</printStdoutOnSuccess>
              <printStderrOnError>true</printStderrOnError>
              <printStderrOnFailure>true</printStderrOnFailure>
              <printStderrOnSuccess>false</printStderrOnSuccess>
            </statelessTestsetInfoReporter>
          </configuration>
          <executions>
            <execution>
              <id>integration-test</id>
              <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
              </goals>
              <configuration>
                <includes>
                  <include>**/*IT.java</include>
                  <include>**/integrationtests/*.java</include>
                  <include>**/it/**/*.java</include>
                </includes>
                <excludes>
                  <exclude>**/*ContainerIT.java</exclude>
                </excludes>
                <systemPropertyVariables>
                  <spotify.test.type>integration</spotify.test.type>
                  <spotify.target.dir>${project.build.directory}</spotify.target.dir>
                </systemPropertyVariables>
              </configuration>
            </execution>
            <execution>
              <id>container-integration-test</id>
              <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
              </goals>
              <configuration>
                <includes>
                  <include>**/*ContainerIT.java</include>
                </includes>
                <systemPropertyVariables>
                  <spotify.test.type>container-integration</spotify.test.type>
                  <spotify.target.dir>${project.build.directory}</spotify.target.dir>
                </systemPropertyVariables>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>3.6.0</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <profiles>
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar-no-fork</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <artifactId>maven-javadoc-plugin</artifactId>
            <configuration>
              <show>private</show>
              <failOnError>false</failOnError>
            </configuration>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.sonatype.central</groupId>
            <artifactId>central-publishing-maven-plugin</artifactId>
          </plugin>

          <plugin>
            <artifactId>maven-gpg-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>jdk8</id>
      <activation>
        <jdk>1.8</jdk>
      </activation>
      <properties>
        <java.version>1.8</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
      </properties>
    </profile>
    <profile>
      <id>jdk9+</id>
      <activation>
        <jdk>[9,)</jdk>
      </activation>
      <properties>
        <!-- Javac introduced the "release" option only in Java 9+.  It
          properly sets up source, target and boot classpath for the best
          compatibility with different versions of Java. -->
        <java.version>8</java.version>
        <maven.compiler.release>${java.version}</maven.compiler.release>
      </properties>
    </profile>
  </profiles>

  <reporting>
    <plugins>
      <plugin>
        <artifactId>maven-project-info-reports-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-changelog-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-report-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-javadoc-plugin</artifactId>
      </plugin>
    </plugins>
  </reporting>
</project>
