<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.ongres</groupId>
  <artifactId>build-parent</artifactId>
  <version>1.0.8</version>
  <packaging>pom</packaging>

  <name>ongres: build parent pom</name>
  <description>Build parent pom for any project</description>

  <url>https://gitlab.com/ongresinc/build-tools</url>

  <inceptionYear>2019</inceptionYear>

  <organization>
    <name>OnGres, Inc.</name>
    <url>https://www.ongres.com</url>
  </organization>

  <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>

  <developers>
    <developer>
      <id>@adescoms</id>
      <name>Adrián Escoms</name>
    </developer>
    <developer>
      <id>@teoincontatto</id>
      <name>Matteo Melli</name>
    </developer>
    <developer>
      <id>@begonapm</id>
      <name>Begoña Pérez Martín</name>
    </developer>
    <developer>
      <id>@jorsol</id>
      <name>Jorge Solórzano</name>
    </developer>
  </developers>

  <scm>
    <url>https://gitlab.com/ongresinc/build-tools</url>
  </scm>

  <distributionManagement>
    <snapshotRepository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <maven.enforce.version>3.6</maven.enforce.version>
    <java.enforce.version>${java.version}</java.enforce.version>
    <maven.compiler.source>${java.version}</maven.compiler.source>
    <maven.compiler.target>${java.version}</maven.compiler.target>

    <!-- Dependencies versions -->
    <checkstyle.version>8.32</checkstyle.version>
    <spotbugs.version>4.0.3</spotbugs.version>
    <log4j2.version>2.13.3</log4j2.version>
    <slf4j.version>1.7.30</slf4j.version>
    <junit5.version>5.6.2</junit5.version>
    <build-resources.version>1.0.7</build-resources.version>

    <!-- Plugin versions -->
    <compiler-plugin.version>3.8.1</compiler-plugin.version>
    <clean-plugin.version>3.1.0</clean-plugin.version>
    <surefire-plugin.version>3.0.0-M4</surefire-plugin.version>
    <failsafe-plugin.version>3.0.0-M4</failsafe-plugin.version>
    <jar-plugin.version>3.2.0</jar-plugin.version>
    <install-plugin.version>3.0.0-M1</install-plugin.version>
    <resources-plugin.version>3.1.0</resources-plugin.version>
    <dependency-plugin.version>3.1.2</dependency-plugin.version>
    <javadoc-plugin.version>3.2.0</javadoc-plugin.version>
    <source-plugin.version>3.2.1</source-plugin.version>
    <gpg-plugin.version>1.6</gpg-plugin.version>
    <nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
    <checkstyle-plugin.version>3.1.1</checkstyle-plugin.version>
    <enforcer-plugin.version>3.0.0-M3</enforcer-plugin.version>
    <spotbugs-plugin.version>4.0.0</spotbugs-plugin.version>
    <maven-shade-plugin.version>3.2.3</maven-shade-plugin.version>
    <build-helper-maven-plugin.version>3.1.0</build-helper-maven-plugin.version>
    <license-maven-plugin.version>2.0.0</license-maven-plugin.version>

    <!-- Checkstyle properties -->
    <checkstyle.config.location>com/ongres/checkstyle/checkstyle.xml</checkstyle.config.location>
    <checkstyle.suppression.location>${project.build.directory}/build-resources/com/ongres/checkstyle/checkstyle-suppressions.xml</checkstyle.suppression.location>
    <checkstyle.consoleOutput>true</checkstyle.consoleOutput>

    <spotbugs.excluded.location>${project.build.directory}/build-resources/com/ongres/spotbugs/spotbugs-exclude.xml</spotbugs.excluded.location>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${slf4j.version}</version>
      </dependency>
      <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-bom</artifactId>
        <version>${log4j2.version}</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
      <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit-bom</artifactId>
        <version>${junit5.version}</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
      <dependency>
        <groupId>com.github.spotbugs</groupId>
        <artifactId>spotbugs-annotations</artifactId>
        <version>${spotbugs.version}</version>
        <exclusions>
          <exclusion>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>jsr305</artifactId>
          </exclusion>
        </exclusions>
      </dependency>
      <dependency>
        <groupId>com.ongres</groupId>
        <artifactId>build-resources</artifactId>
        <version>${build-resources.version}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.github.spotbugs</groupId>
      <artifactId>spotbugs-annotations</artifactId>
      <scope>provided</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${compiler-plugin.version}</version>
        <configuration>
          <compilerArgs>
            <arg>-Xlint:all</arg>
          </compilerArgs>
          <showDeprecation>true</showDeprecation>
          <showWarnings>false</showWarnings>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${surefire-plugin.version}</version>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>${failsafe-plugin.version}</version>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-clean-plugin</artifactId>
        <version>${clean-plugin.version}</version>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>${resources-plugin.version}</version>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>${dependency-plugin.version}</version>
        <executions>
          <execution>
            <id>unpack-build-resources</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>com.ongres</groupId>
                  <artifactId>build-resources</artifactId>
                  <version>${build-resources.version}</version>
                </artifactItem>
              </artifactItems>
              <outputDirectory>${project.build.directory}/build-resources</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>${jar-plugin.version}</version>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-install-plugin</artifactId>
        <version>${install-plugin.version}</version>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>${enforcer-plugin.version}</version>
        <executions>
          <execution>
            <id>enforce-versions</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireMavenVersion>
                  <version>[${maven.enforce.version},)</version>
                </requireMavenVersion>
                <requireJavaVersion>
                  <version>[${java.enforce.version},)</version>
                </requireJavaVersion>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>${checkstyle-plugin.version}</version>
        <executions>
          <execution>
            <id>validate</id>
            <configuration>
              <configLocation>${checkstyle.config.location}</configLocation>
              <suppressionsLocation>${checkstyle.suppression.location}</suppressionsLocation>
              <propertyExpansion>config_loc=${project.build.directory}/build-resources/com/ongres/checkstyle/</propertyExpansion>
              <consoleOutput>${checkstyle.consoleOutput}</consoleOutput>
              <violationSeverity>error</violationSeverity>
              <failOnViolation>true</failOnViolation>
              <failsOnError>true</failsOnError>
              <includeTestSourceDirectory>true</includeTestSourceDirectory>
            </configuration>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>com.puppycrawl.tools</groupId>
            <artifactId>checkstyle</artifactId>
            <version>${checkstyle.version}</version>
          </dependency>
          <dependency>
            <groupId>com.ongres</groupId>
            <artifactId>build-resources</artifactId>
            <version>${build-resources.version}</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>${javadoc-plugin.version}</version>
        <configuration>
          <failOnWarnings>false</failOnWarnings>
        </configuration>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-shade-plugin</artifactId>
          <version>${maven-shade-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>${build-helper-maven-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>license-maven-plugin</artifactId>
          <version>${license-maven-plugin.version}</version>
          <configuration>
            <addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
            <processStartTag>&#160;&#167;&#160;</processStartTag>
            <sectionDelimiter>&#160;&#160;&#160;</sectionDelimiter>
            <processEndTag>&#167;&#160;&#167;</processEndTag>
            <emptyLineAfterHeader>true</emptyLineAfterHeader>
            <trimHeaderLine>true</trimHeaderLine>
            <roots>
              <root>src</root>
            </roots>
          </configuration>
        </plugin>
        <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <versionRange>[${dependency-plugin.version},)</versionRange>
                    <goals>
                      <goal>unpack</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore></ignore>
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <profiles>
    <profile>
      <id>jdk9+</id>
      <activation>
        <jdk>[9,)</jdk>
      </activation>
      <properties>
        <maven.compiler.release>${java.release.version}</maven.compiler.release>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>set-graal-home</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>bsh-property</goal>
                </goals>
                <configuration>
                  <properties>
                    <property>java.release.version</property>
                  </properties>
                  <source>
                    java.release.version = project.getProperties().getProperty("java.version") != null
                      &amp;&amp; project.getProperties().getProperty("java.version").startsWith("1.")
                      ? project.getProperties().getProperty("java.version").substring(2)
                      : project.getProperties().getProperty("java.version");
                  </source>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>safer</id> <!-- Slower but safer profile used to look for errors before pushing to SCM -->
      <build>
        <plugins>
          <plugin>
            <groupId>com.github.spotbugs</groupId>
            <artifactId>spotbugs-maven-plugin</artifactId>
            <version>${spotbugs-plugin.version}</version>
            <configuration>
              <excludeFilterFile>${spotbugs.excluded.location}</excludeFilterFile>
              <effort>Max</effort>
              <threshold>Low</threshold>
              <xmlOutput>true</xmlOutput>
            </configuration>
            <executions>
              <execution>
                <goals>
                  <goal>check</goal>
                </goals>
              </execution>
            </executions>
            <dependencies>
              <!-- overwrite dependency on spotbugs if you want to specify 
                the version of spotbugs -->
              <dependency>
                <groupId>com.github.spotbugs</groupId>
                <artifactId>spotbugs</artifactId>
                <version>${spotbugs.version}</version>
              </dependency>
            </dependencies>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>integration</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>${failsafe-plugin.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
                <configuration>
                  <trimStackTrace>false</trimStackTrace>
                  <includes>
                    <include>**/It*.java</include>
                    <include>**/*It.java</include>
                    <include>**/*ItCase.java</include>
                  </includes>
                  <excludes>
                  </excludes>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>${source-plugin.version}</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>${javadoc-plugin.version}</version>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>${gpg-plugin.version}</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <version>${nexus-staging-maven-plugin.version}</version>
            <extensions>true</extensions>
            <configuration>
              <serverId>ossrh</serverId>
              <nexusUrl>https://oss.sonatype.org/</nexusUrl>
              <autoReleaseAfterClose>true</autoReleaseAfterClose>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
