<!--

    Copyright (C) 2015 Red Hat, Inc.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<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.redhat.rcm</groupId>
  <artifactId>redhat-releng-tools</artifactId>
  <version>11</version>
  <packaging>pom</packaging>

  <name>Red Hat RelEng Parent</name>

  <url>https://github.com/release-engineering/redhat-releng-tools</url>

  <description>Top-level parent POM for Red Hat Tooling.</description>
  <inceptionYear>2015</inceptionYear>

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

  <developers>
    <developer>
      <id>rnc</id>
      <name>Nick Cross</name>
      <email>ncross@redhat.com</email>
    </developer>
    <developer>
      <id>jdcasey</id>
      <email>jdcasey@commonjava.org</email>
      <name>John Casey</name>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:https://github.com/release-engineering/redhat-releng-tools.git</connection>
    <developerConnection>scm:git:git@github.com:release-engineering/redhat-releng-tools.git</developerConnection>
    <url>http://github.com/release-engineering/redhat-releng-tools</url>
    <tag>redhat-releng-tools-11</tag>
  </scm>

  <properties>
    <javaVersion>11</javaVersion>
    <javaTestVersion>${javaVersion}</javaTestVersion>
    <projectOwner>Red Hat, Inc.</projectOwner>
    <projectEmail>jcasey@redhat.com</projectEmail>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <version.plugin.assembly>3.3.0</version.plugin.assembly>
    <version.plugin.clean>3.1.0</version.plugin.clean>
    <version.plugin.compiler>3.8.1</version.plugin.compiler>
    <version.plugin.deploy>3.0.0-M1</version.plugin.deploy>
    <version.plugin.enforcer>3.0.0-M3</version.plugin.enforcer>
    <version.plugin.failsafe>3.0.0-M5</version.plugin.failsafe>
    <version.plugin.gpg>1.6</version.plugin.gpg>
    <version.plugin.install>3.0.0-M1</version.plugin.install>
    <version.plugin.jar>3.2.0</version.plugin.jar>
    <version.plugin.javadoc>3.2.0</version.plugin.javadoc>
    <version.plugin.plexus-component-metadata>2.1.0</version.plugin.plexus-component-metadata>
    <version.plugin.sisu>0.3.4</version.plugin.sisu>
    <version.plugin.plugin>3.6.0</version.plugin.plugin>
    <version.plugin.release>3.0.0-M4</version.plugin.release>
    <version.plugin.resources>3.2.0</version.plugin.resources>
    <version.plugin.site>3.9.1</version.plugin.site>
    <version.plugin.source>3.2.1</version.plugin.source>
    <version.plugin.surefire>3.0.0-M5</version.plugin.surefire>
    <version.plugin.pmd>3.13.0</version.plugin.pmd>
    <version.plugin.license>4.1</version.plugin.license>

    <enforceManagedDeps>true</enforceManagedDeps>

    <unEnforcedPlugins>org.eclipse.m2e:lifecycle-mapping</unEnforcedPlugins>
    <enforcedMavenVersion>[3.3.9,)</enforcedMavenVersion>
    <enforcedJavaVersion>${javaVersion}</enforcedJavaVersion>

    <enforceBestPractices>true</enforceBestPractices>
    <enforceStandards>true</enforceStandards>
    <enforceVersions>true</enforceVersions>
    <enforceTripHazards>true</enforceTripHazards>
    <!-- Defaults to true but can cause issues with Gradle TestKit: https://github.com/gradle/gradle/issues/15269 -->
    <addJarIndex>true</addJarIndex>
  </properties>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>${version.plugin.compiler}</version>
          <configuration>
            <showWarnings>true</showWarnings>
            <debug>true</debug>
            <source>${javaVersion}</source>
            <target>${javaVersion}</target>
            <testSource>${javaTestVersion}</testSource>
            <testTarget>${javaTestVersion}</testTarget>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>${version.plugin.clean}</version>
        </plugin>

        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>${version.plugin.deploy}</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>${version.plugin.install}</version>
        </plugin>
        <plugin>
          <artifactId>maven-site-plugin</artifactId>
          <version>${version.plugin.site}</version>
        </plugin>
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>${version.plugin.resources}</version>
        </plugin>
        <plugin>
          <artifactId>maven-source-plugin</artifactId>
          <version>${version.plugin.source}</version>
        </plugin>

        <plugin>
          <artifactId>maven-plugin-plugin</artifactId>
          <version>${version.plugin.plugin}</version>
          <executions>
            <execution>
              <id>generate-descriptor</id>
              <goals>
                <goal>descriptor</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.eclipse.sisu</groupId>
          <artifactId>sisu-maven-plugin</artifactId>
          <version>${version.plugin.sisu}</version>
          <executions>
            <execution>
              <id>generate-index</id>
              <goals>
                <goal>main-index</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.codehaus.plexus</groupId>
          <artifactId>plexus-component-metadata</artifactId>
          <version>${version.plugin.plexus-component-metadata}</version>
          <executions>
            <execution>
              <id>components.xml</id>
              <goals>
                <goal>generate-metadata</goal>
                <goal>generate-test-metadata</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${version.plugin.surefire}</version>
          <configuration>
            <excludes>
              <exclude>**/*Fixture*.java</exclude>
              <exclude>**/fixture/*.java</exclude>
              <exclude>**/*Live*.java</exclude>
              <exclude>**/live/*.java</exclude>
              <exclude>**/live/**/*.java</exclude>
            </excludes>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>${version.plugin.failsafe}</version>
          <configuration>
            <excludes>
              <exclude>**/*Fixture*.java</exclude>
              <exclude>**/fixture/*.java</exclude>
            </excludes>
            <includes>
              <exclude>**/*Live*.java</exclude>
              <include>**/live/*.java</include>
              <include>**/live/**/*.java</include>
            </includes>
          </configuration>
          <executions>
            <execution>
              <id>integration-tests</id>
              <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-release-plugin</artifactId>
          <version>${version.plugin.release}</version>
          <configuration>
            <autoVersionSubmodules>true</autoVersionSubmodules>
            <mavenExecutorId>forked-path</mavenExecutorId>
            <arguments>-Prelease</arguments>
            <releaseProfiles>skipLicenseOnPerformRelease</releaseProfiles>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-enforcer-plugin</artifactId>
          <version>${version.plugin.enforcer}</version>
          <dependencies>
            <dependency>
              <groupId>org.commonjava.maven.enforcer</groupId>
              <artifactId>enforce-managed-deps-rule</artifactId>
              <version>1.3</version>
            </dependency>
          </dependencies>
          <executions>
            <execution>
              <id>avoid-trip-hazards</id>
              <goals>
                <goal>enforce</goal>
              </goals>
              <phase>initialize</phase>
              <configuration>
                <fail>${enforceTripHazards}</fail>
                <rules>
                  <requireSameVersions>
                    <dependencies>
                      <dependency>${project.groupId}*</dependency>
                    </dependencies>
                  </requireSameVersions>
                </rules>
              </configuration>
            </execution>
            <execution>
              <id>enforce-commonjava-standards</id>
              <goals>
                <goal>enforce</goal>
              </goals>
              <phase>process-classes</phase>
              <configuration>
                <fail>${enforceStandards}</fail>
                <rules>
                  <requireManagedDeps implementation="org.commonjava.maven.enforcer.rule.EnforceManagedDepsRule">
                    <!-- <message>Capture dependencies in top-level dependencyManagement section for easy reference.</message> -->
                    <checkProfiles>false</checkProfiles>
                    <failOnViolation>${enforceManagedDeps}</failOnViolation>
                  </requireManagedDeps>
                </rules>
              </configuration>
            </execution>
            <execution>
              <id>enforce-best-practices</id>
              <goals>
                <goal>enforce</goal>
              </goals>
              <phase>initialize</phase>
              <configuration>
                <fail>${enforceBestPractices}</fail>
                <rules>
                  <reactorModuleConvergence />
                  <requireNoRepositories />
                  <requirePluginVersions>
                    <banLatest />
                    <banRelease />
                    <banSnapshots />
                    <unCheckedPluginList>${unEnforcedPlugins}</unCheckedPluginList>
                  </requirePluginVersions>
                </rules>
              </configuration>
            </execution>
            <execution>
              <id>enforce-versions</id>
              <goals>
                <goal>enforce</goal>
              </goals>
              <configuration>
                <fail>${enforceVersions}</fail>
                <rules>
                  <requireMavenVersion>
                    <message>To build this project Maven ${enforcedMavenVersion}(or greater) is required. Please install it.</message>
                    <version>${enforcedMavenVersion}</version>
                  </requireMavenVersion>
                  <requireJavaVersion>
                    <version>${enforcedJavaVersion}</version>
                    <message>To build this project JDK ${enforcedJavaVersion} (or greater) is required. Please install it.</message>
                  </requireJavaVersion>
                </rules>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>${version.plugin.assembly}</version>
          <configuration>
            <archive>
              <index>${addJarIndex}</index>
              <manifest>
                <addDefaultSpecificationEntries>
                  true
                </addDefaultSpecificationEntries>
                <addDefaultImplementationEntries>
                  true
                </addDefaultImplementationEntries>
              </manifest>
              <manifestEntries>
                <Implementation-URL>${project.url}</Implementation-URL>
                <Java-Version>${java.version}</Java-Version>
                <Java-Vendor>${java.vendor}</Java-Vendor>
                <Os-Name>${os.name}</Os-Name>
                <Os-Arch>${os.arch}</Os-Arch>
                <Os-Version>${os.version}</Os-Version>
                <Scm-Url>${project.scm.url}</Scm-Url>
                <Scm-Connection>${project.scm.connection}</Scm-Connection>
                <Scm-Revision>${buildNumber}</Scm-Revision>
                <Build-Timestamp>${datetime}</Build-Timestamp>
              </manifestEntries>
            </archive>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>${version.plugin.jar}</version>
          <configuration>
            <archive>
              <index>${addJarIndex}</index>
              <manifest>
                <addDefaultSpecificationEntries>
                  true
                </addDefaultSpecificationEntries>
                <addDefaultImplementationEntries>
                  true
                </addDefaultImplementationEntries>
              </manifest>
              <manifestEntries>
                <Implementation-URL>${project.url}</Implementation-URL>
                <Java-Version>${java.version}</Java-Version>
                <Java-Vendor>${java.vendor}</Java-Vendor>
                <Os-Name>${os.name}</Os-Name>
                <Os-Arch>${os.arch}</Os-Arch>
                <Os-Version>${os.version}</Os-Version>
                <Scm-Url>${project.scm.url}</Scm-Url>
                <Scm-Connection>${project.scm.connection}</Scm-Connection>
                <Scm-Revision>${buildNumber}</Scm-Revision>
              </manifestEntries>
            </archive>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>${version.plugin.javadoc}</version>
          <configuration>
             <header><![CDATA[<b>${project.name} ${project.version}</b>]]></header>
             <footer><![CDATA[<b>${project.name} ${project.version}</b>]]></footer>
             <archive>
                <index>${addJarIndex}</index>
                <manifest>
                  <addDefaultSpecificationEntries>
                    true
                  </addDefaultSpecificationEntries>
                  <addDefaultImplementationEntries>
                    true
                  </addDefaultImplementationEntries>
                </manifest>
                <manifestEntries>
                  <Implementation-URL>${project.url}</Implementation-URL>
                  <Java-Version>${java.version}</Java-Version>
                  <Java-Vendor>${java.vendor}</Java-Vendor>
                  <Os-Name>${os.name}</Os-Name>
                  <Os-Arch>${os.arch}</Os-Arch>
                  <Os-Version>${os.version}</Os-Version>
                  <Scm-Url>${project.scm.url}</Scm-Url>
                  <Scm-Connection>${project.scm.connection}</Scm-Connection>
                  <Scm-Revision>${buildNumber}</Scm-Revision>
                </manifestEntries>
              </archive>
          </configuration>
          <executions>
            <execution>
              <id>attach-javadocs</id>
              <goals>
                <goal>jar</goal>
              </goals>
              <configuration>
                <detectOfflineLinks>false</detectOfflineLinks>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>buildnumber-maven-plugin</artifactId>
          <version>1.4</version>
          <executions>
            <execution>
              <phase>validate</phase>
              <id>buildnumber</id>
              <goals>
                <goal>create</goal>
              </goals>
              <configuration>
                <shortRevisionLength>8</shortRevisionLength>
                <timestampFormat>{0,date,dd MMMM yyyy}</timestampFormat>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-pmd-plugin</artifactId>
          <version>${version.plugin.pmd}</version>
          <configuration>
            <targetJdk>${javaVersion}</targetJdk>
            <ruleset>pmd-ruleset.xml</ruleset>
          </configuration>
          <executions>
            <execution>
              <phase>process-sources</phase>
              <goals>
                <goal>check</goal>
                <goal>pmd</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>com.mycila</groupId>
          <artifactId>license-maven-plugin</artifactId>
          <version>${version.plugin.license}</version>
          <configuration>
            <header>APACHE-2-SIMPLIFIED-COPYRIGHT.txt</header>
            <properties>
              <owner>${projectOwner}</owner>
              <email>${projectEmail}</email>
            </properties>
            <excludes>
              <exclude>**/README</exclude>
              <exclude>**/LICENSE*</exclude>
            </excludes>
          </configuration>
          <dependencies>
            <dependency>
              <groupId>com.mycila</groupId>
              <artifactId>license-maven-plugin-git</artifactId>
              <version>${version.plugin.license}</version>
            </dependency>
            <dependency>
              <groupId>com.redhat.rcm</groupId>
              <artifactId>redhat-releng-license-templates</artifactId>
              <version>2</version>
            </dependency>
          </dependencies>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>buildnumber-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-enforcer-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-javadoc-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>formatting</id>
      <build>
        <plugins>
          <plugin>
            <groupId>com.mycila</groupId>
            <artifactId>license-maven-plugin</artifactId>
            <executions>
              <execution>
                <phase>process-sources</phase>
                <goals>
                  <goal>format</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>cq</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-pmd-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>com.mycila</groupId>
            <artifactId>license-maven-plugin</artifactId>
            <executions>
              <execution>
                <goals>
                  <goal>check</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>${version.plugin.source}</version>
            <configuration>
              <archive>
                <index>${addJarIndex}</index>
                <manifest>
                  <addDefaultSpecificationEntries>
                    true
                  </addDefaultSpecificationEntries>
                  <addDefaultImplementationEntries>
                    true
                  </addDefaultImplementationEntries>
                </manifest>
                <manifestEntries>
                  <Implementation-URL>${project.url}</Implementation-URL>
                  <Java-Version>${java.version}</Java-Version>
                  <Java-Vendor>${java.vendor}</Java-Vendor>
                  <Os-Name>${os.name}</Os-Name>
                  <Os-Arch>${os.arch}</Os-Arch>
                  <Os-Version>${os.version}</Os-Version>
                  <Scm-Url>${project.scm.url}</Scm-Url>
                  <Scm-Connection>${project.scm.connection}</Scm-Connection>
                  <Scm-Revision>${buildNumber}</Scm-Revision>
                </manifestEntries>
              </archive>
            </configuration>
            <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-gpg-plugin</artifactId>
            <version>${version.plugin.gpg}</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>skipLicenseOnPerformRelease</id>
      <properties>
        <license.skip>true</license.skip>
      </properties>
    </profile>
  </profiles>

  <distributionManagement>
    <repository>
      <id>sonatype-nexus-staging</id>
      <name>Release Repository</name>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
    <snapshotRepository>
      <id>sonatype-nexus-snapshots</id>
      <name>Sonatype Nexus</name>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
  </distributionManagement>

</project>
