<?xml version="1.0" encoding="utf-8"?>
<!--
  #%L
  HandcraftedBits Parent POM
  %%
  Copyright (C) 2015 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.
  #L%
  -->
<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.0.1</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>
    <name.license>apache_v2</name.license>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <version.java>1.7</version.java>
    
    <version.dep.codequality>1.0.0</version.dep.codequality>
    <version.dep.junit>4.12</version.dep.junit>
    
    <version.plugin.checkstyle>2.17</version.plugin.checkstyle>
    <version.plugin.compiler>3.3</version.plugin.compiler>
    <version.plugin.findbugs>3.0.3</version.plugin.findbugs>
    <version.plugin.gpg>1.6</version.plugin.gpg>
    <version.plugin.javadoc>2.10.3</version.plugin.javadoc>
    <version.plugin.license>1.8</version.plugin.license>
    <version.plugin.nexus-staging>1.6.5</version.plugin.nexus-staging>
    <version.plugin.source>2.4</version.plugin.source>
  </properties>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
      <resource>
        <directory>src/test/resources</directory>
        <filtering>true</filtering>
      </resource>
    </resources>
  </build>

  <profiles>
    <!-- Plugins for Java projects -->
    <profile>
      <id>java-project</id>
      <activation>
        <activeByDefault>false</activeByDefault>
        <file>
          <exists>${basedir}/src/main/java</exists>
        </file>
      </activation>

      <dependencies>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>${version.dep.junit}</version>
          <scope>test</scope>
        </dependency>
      </dependencies>

      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>${version.plugin.compiler}</version>
              <configuration>
                <source>${version.java}</source>
                <target>${version.java}</target>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
        
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>findbugs-maven-plugin</artifactId>
            <version>${version.plugin.findbugs}</version>
            <executions>
              <execution>
                <id>check-findbugs</id>
                <phase>verify</phase>
                <goals>
                  <goal>check</goal>
                </goals>
                <configuration>
                  <maxRank>20</maxRank>
                  <threshold>Low</threshold>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>${version.plugin.checkstyle}</version>
            <dependencies>
              <dependency>
                <groupId>com.handcraftedbits</groupId>
                <artifactId>handcraftedbits-codequality</artifactId>
                <version>${version.dep.codequality}</version>
              </dependency>
            </dependencies>
            <executions>
              <execution>
                <id>check-style</id>
                <phase>process-classes</phase>
                <goals>
                  <goal>check</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <configLocation>checkstyle_handcraftedbits.xml</configLocation>
              <logViolationsToConsole>true</logViolationsToConsole>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>${version.plugin.javadoc}</version>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>${version.plugin.source}</version>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    
    <!-- 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>org.codehaus.mojo</groupId>
            <artifactId>license-maven-plugin</artifactId>
            <version>${version.plugin.license}</version>
            <executions>
              <execution>
                <id>update-copyright</id>
                <phase>process-sources</phase>
                <goals>
                  <goal>update-file-header</goal>
                </goals>
                <configuration>
                  <addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
                  <licenseName>${name.license}</licenseName>
                  <roots combine.children="append">
                    <root>.</root>
                  </roots>
                  <includes combine.children="append">
                    <include>pom.xml</include>
                    <include>src/main/java/**/*</include>
                    <include>src/main/resources/**/*.properties</include>
                    <include>src/main/resources/**/*.xml</include>
                    <include>src/test/java/**/*</include>
                  </includes>
                </configuration>
              </execution>
              <execution>
                <id>update-license</id>
                <phase>process-sources</phase>
                <goals>
                  <goal>update-project-license</goal>
                </goals>
                <configuration>
                  <licenseName>${name.license}</licenseName>
                  <licenseFile>${basedir}/LICENSE</licenseFile>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
