<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2015-2020 HandcraftedBits

  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:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         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.handcraftedbits</groupId>
  <artifactId>handcraftedbits-parent</artifactId>
  <packaging>pom</packaging>
  <name>HandcraftedBits Parent POM</name>
  <description>A parent POM used by HandcraftedBits projects</description>
  <url>https://github.com/handcraftedbits/handcraftedbits-parent</url>
  <version>1.4.2</version>
  <inceptionYear>2015</inceptionYear>

  <developers>
    <developer>
      <name>Curtiss Howard</name>
      <email>opensource@handcraftedbits.com</email>
      <organization>HandcraftedBits</organization>
      <organizationUrl>https://github.com/handcraftedbits</organizationUrl>
    </developer>
  </developers>
  <organization>
    <name>HandcraftedBits</name>
    <url>https://github.com/handcraftedbits</url>
  </organization>
  <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0</url>
    </license>
  </licenses>

  <scm>
    <url>https://github.com/handcraftedbits/handcraftedbits-parent</url>
    <connection>scm:git:git://github.com/handcraftedbits/handcraftedbits-parent.git</connection>
    <developerConnection>scm:git:git@github.com:handcraftedbits/handcraftedbits-parent.git</developerConnection>
  </scm>
  <issueManagement>
    <url>https://github.com/handcraftedbits/handcraftedbits-parent/issues</url>
    <system>GitHub Issues</system>
  </issueManagement>

  <properties>
    <license.type>ASL2</license.type>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
   
    <version.dep.handcraftedbits-license>1.0.2</version.dep.handcraftedbits-license>
    <version.maven.minimum>3.5.0</version.maven.minimum>
    
    <version.plugin.enforcer>3.0.0-M3</version.plugin.enforcer>
    <version.plugin.gpg>1.6</version.plugin.gpg>
    <version.plugin.license>3.0</version.plugin.license>
    <version.plugin.nexus-staging>1.6.8</version.plugin.nexus-staging>
  </properties>

  <modules>
    <module>handcraftedbits-parent-java</module>
  </modules>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
    </resources>
    
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>${version.plugin.enforcer}</version>
        <executions>
          <execution>
            <id>enforce-maven-version</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireMavenVersion>
                  <version>${version.maven.minimum}</version>
                </requireMavenVersion>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <!-- Release/deploy to Maven Central -->
    <profile>
      <id>release</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>

      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>${version.plugin.gpg}</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <version>${version.plugin.nexus-staging}</version>
            <configuration>
              <serverId>ossrh</serverId>
              <nexusUrl>https://oss.sonatype.org/</nexusUrl>
              <autoReleaseAfterClose>true</autoReleaseAfterClose>
            </configuration>
          </plugin>
        </plugins>
      </build>

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

    <!-- Update copyright on source files -->
    <profile>
      <id>update-copyright</id>
      <activation>
        <activeByDefault>false</activeByDefault>
        <file>
          <exists>${basedir}/LICENSE</exists>
        </file>
      </activation>

      <build>
        <plugins>
          <plugin>
            <groupId>com.mycila</groupId>
            <artifactId>license-maven-plugin</artifactId>
            <version>${version.plugin.license}</version>
            <dependencies>
              <dependency>
                <groupId>com.handcraftedbits</groupId>
                <artifactId>handcraftedbits-license</artifactId>
                <version>${version.dep.handcraftedbits-license}</version>
              </dependency>
            </dependencies>
            <executions>
              <execution>
                <id>update-copyright</id>
                <phase>process-sources</phase>
                <goals>
                  <goal>format</goal>
                </goals>
                <configuration>
                  <aggregate>true</aggregate>
                  <header>license/${license.type}</header>
                  <headerDefinitions>
                    <headerDefinition>license/style/xmlstyle.xml</headerDefinition>
                  </headerDefinitions>
                  <includes combine.children="append">
                    <include>**/pom.xml</include>
                    <include>**/*.java</include>
                    <include>**/src/it/**/invoker.properties</include>
                    <include>**/src/it/**/verify.groovy</include>
                    <include>**/src/it/resources/**/*.properties</include>
                    <include>**/src/it/resources/**/*.xml</include>
                    <include>**/src/main/codequality/**/*.xml</include>
                    <include>**/src/main/resources/**/*.properties</include>
                    <include>**/src/main/resources/**/*.xml</include>
                    <include>**/src/test/resources/**/*.properties</include>
                    <include>**/src/test/resources/**/*.xml</include>
                  </includes>
                  <lineLength>120</lineLength>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
