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

  <modelVersion>4.0.0</modelVersion>

  <groupId>com.github.felfert</groupId>
  <artifactId>parent</artifactId>
  <packaging>pom</packaging>
  <version>1.14</version>
  <name>Parent POM for com.github.felfert</name>
  <url>https://github.com/felfert/parent</url>
  <inceptionYear>2016</inceptionYear>

  <description>Standard parent POM for com.github.felfert</description>
  <licenses>
    <license>
      <name>The Apache Software License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>

  <developers>
    <developer>
      <id>felfert</id>
      <name>Fritz Elfert</name>
      <email>fritz-github@fritz-elfert.de</email>
      <timezone>Europe/Berlin</timezone>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:git://github.com/felfert/parent.git</connection>
    <developerConnection>scm:git:git@github.com:felfert/parent.git</developerConnection>
    <url>http://github.com/felfert/parent</url>
    <tag>parent-1.14</tag>
  </scm>

  <issueManagement>
    <system>Github</system>
    <url>http://github.com/felfert/parent/</url>
  </issueManagement>

  <properties>
    <generateBackupPoms>false</generateBackupPoms>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <maven.version>3.9.9</maven.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.13.2</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>com.github.spotbugs</groupId>
        <artifactId>spotbugs-annotations</artifactId>
        <version>4.10.2</version>
        <optional>true</optional>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <build>
    <pluginManagement>
      <plugins>

        <!-- Compile java -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.15.0</version>
          <configuration>
            <showDeprecation>true</showDeprecation>
            <showWarnings>true</showWarnings>
          </configuration>
        </plugin>

        <!-- Static code analysis with PMD -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-pmd-plugin</artifactId>
          <version>3.28.0</version>
          <configuration>
            <linkXRef>false</linkXRef>
            <failOnViolation>true</failOnViolation>
            <verbose>true</verbose>
          </configuration>
          <executions>
            <execution>
              <phase>verify</phase>
              <goals>
                <goal>check</goal>
                <goal>cpd-check</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <!-- Static code analysis with spotbugs -->
        <plugin>
          <groupId>com.github.spotbugs</groupId>
          <artifactId>spotbugs-maven-plugin</artifactId>
          <version>4.10.2.0</version>
            <dependencies>
              <dependency>
                <groupId>com.github.spotbugs</groupId>
                <artifactId>spotbugs</artifactId>
                <version>4.10.2</version>
              </dependency>
            </dependencies>
          <executions>
            <execution>
              <phase>verify</phase>
              <goals>
                <goal>check</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <!-- Static code analysis with checkstyle -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <version>3.6.0</version>
        </plugin>

        <!-- Format code with spotless -->
        <plugin>
          <groupId>com.diffplug.spotless</groupId>
          <artifactId>spotless-maven-plugin</artifactId>
          <version>3.7.0</version>
          <configuration>
            <java>
              <endWithNewline />
              <importOrder />
              <indent>
                <spaces>true</spaces>
              </indent>
              <palantirJavaFormat />
              <removeUnusedImports />
              <toggleOffOn />
              <trimTrailingWhitespace />
            </java>
            <pom>
              <includes>
                <!-- Don't touch my pom.xml! -->
                <include>/dev/null</include>
              </includes>
            </pom>
          </configuration>
        </plugin>

        <!-- Generate source jar -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>3.4.0</version>
          <executions>
            <execution>
              <id>attach-sources</id>
              <goals>
                <goal>jar</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <!-- Generate javadoc jar -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>3.12.0</version>
          <executions>
            <execution>
              <id>attach-javadocs</id>
              <goals>
                <goal>jar</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <!-- Generate sources from templates -->
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>templating-maven-plugin</artifactId>
          <version>3.1.0</version>
          <executions>
            <execution>
              <id>filtering-java-templates</id>
              <goals>
                <goal>filter-sources</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <!-- Sign artefacts -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-gpg-plugin</artifactId>
          <version>3.2.8</version>
          <!-- configuration in ~/.m2/settings.xml -->
          <executions>
            <execution>
              <id>sign-artifacts</id>
              <phase>verify</phase>
              <goals>
                <goal>sign</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <!-- Upload to central -->
        <plugin>
          <groupId>org.sonatype.central</groupId>
          <artifactId>central-publishing-maven-plugin</artifactId>
          <version>0.11.0</version>
          <extensions>true</extensions>
          <configuration>
            <autoPublish>true</autoPublish>
            <deploymentName>${project.artifactId}-${project.version}</deploymentName>
            <publishingServerId>central</publishingServerId>
            <!--
               The central publishing plugin has an eventual consistency bug
               here where the API may give a 404 for a short time before reporting
               the publication as in progress. This crashes the plugin and erroneously
               forces a revert to occur when it is not needed. For now, just hope
               that the publication succeeds at some point instead of waiting for it.
            -->
            <!-- <waitUntil>published</waitUntil> -->
          </configuration>
        </plugin>

        <!-- Release helper -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-release-plugin</artifactId>
          <version>3.3.1</version>
          <configuration>
            <autoVersionSubmodules>true</autoVersionSubmodules>
            <releaseProfiles>release</releaseProfiles>
            <goals>deploy</goals>
          </configuration>
        </plugin>

      </plugins>
    </pluginManagement>

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>3.6.3</version>
        <executions>
          <execution>
            <id>enforce-maven</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireMavenVersion>
                  <version>${maven.version}</version>
                </requireMavenVersion>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-release-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.sonatype.central</groupId>
        <artifactId>central-publishing-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>release</id>
      <build>
        <!-- activate GPG plugin only on release -->
        <plugins>
          <plugin>
            <artifactId>maven-gpg-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>parent-checkstyle</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <executions>
              <execution>
                <id>validate</id>
                <phase>validate</phase>
                <goals>
                  <goal>check</goal>
                </goals>
              </execution>
            </executions>
            <dependencies>
              <dependency>
                <groupId>com.puppycrawl.tools</groupId>
                <artifactId>checkstyle</artifactId>
                <version>13.6.0</version>
              </dependency>
            </dependencies>
            <configuration>
              <configLocation>google_checks.xml</configLocation>
              <inputEncoding>UTF-8</inputEncoding>
              <consoleOutput>true</consoleOutput>
              <failsOnError>true</failsOnError>
              <violationSeverity>warning</violationSeverity>
              <linkXRef>false</linkXRef>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <distributionManagement>
    <snapshotRepository>
      <id>central</id>
      <url>https://central.sonatype.com/repository/maven-snapshots/</url>
    </snapshotRepository>
    <repository>
      <id>central</id>
      <url>https://central.sonatype.com/</url>
    </repository>
    <site>
      <id>local</id>
      <url>file:///tmp/mysite</url>
    </site>
  </distributionManagement>

</project>
