<?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.mainstreethub</groupId>
  <artifactId>parent-pom</artifactId>
  <version>1.6.3</version>
  <packaging>pom</packaging>
  <name>Main Street Hub parent pom</name>
  <description>The parent pom for all Main Street Hub projects.</description>
  <url>https://github.com/mainstreethub/parent-pom</url>

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

  <developers>
    <developer>
      <name>Brandon Beck</name>
      <email>brandon.beck@mainstreethub.com</email>
      <organization>Main Street Hub</organization>
      <organizationUrl>http://www.mainstreethub.com</organizationUrl>
    </developer>
  </developers>

  <scm>
    <url>https://github.com/mainstreethub/parent-pom</url>
    <connection>scm:git:https://github.com/mainstreethub/parent-pom</connection>
    <developerConnection>scm:git:https://github.com/mainstreethub/parent-pom</developerConnection>
    <tag>HEAD</tag>
  </scm>

  <properties>
    <!-- All code/reports are in UTF-8 -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

    <!-- The minimum java version, children can override this if necessary. -->
    <java.minimum.version>1.8</java.minimum.version>
  </properties>

  <!-- This configures the publication of jars to the S3 bucket by default. -->
  <distributionManagement>
    <repository>
      <id>maven-s3-release-repo</id>
      <name>S3 Release Repository</name>
      <url>s3://artifacts.mainstreethub.com/maven/releases</url>
    </repository>
    <snapshotRepository>
      <id>maven-s3-snapshot-repo</id>
      <name>S3 Snapshot Repository</name>
      <url>s3://artifacts.mainstreethub.com/maven/snapshots</url>
    </snapshotRepository>
  </distributionManagement>

  <!-- This configures the reading of jars from the S3 bucket. -->
  <repositories>
    <repository>
      <id>maven-s3-release-repo</id>
      <name>S3 Release Repository</name>
      <url>s3://artifacts.mainstreethub.com/maven/releases</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
    <repository>
      <id>maven-s3-snapshot-repo</id>
      <name>S3 Release Repository</name>
      <url>s3://artifacts.mainstreethub.com/maven/snapshots</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

  <build>
    <!-- These plugins take effect for all child poms of this one. -->
    <pluginManagement>
      <plugins>
        <!-- Enforce minimum Maven and Java versions. -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-enforcer-plugin</artifactId>
          <version>1.3.1</version>
          <executions>
            <execution>
              <id>enforce-versions</id>
              <phase>initialize</phase>
              <goals>
                <goal>enforce</goal>
              </goals>
              <configuration>
                <rules>
                  <requireMavenVersion>
                    <version>3.0</version>
                  </requireMavenVersion>
                  <requireJavaVersion>
                    <version>${java.minimum.version}</version>
                  </requireJavaVersion>
                  <dependencyConvergence />
                </rules>
              </configuration>
            </execution>
          </executions>
        </plugin>

        <!-- The compiler should always build code using the minimum version. -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.7.0</version>
          <configuration>
            <source>${java.minimum.version}</source>
            <target>${java.minimum.version}</target>
            <compilerArgs>
              <arg>-Werror</arg>
              <arg>-Xlint:all</arg>

              <!--
                We have a lot of annotations that are just markers for things and not used by
                annotation processors.  This argument will make javac not produce a warning
                message for annotations that are used that lack processors.  This is important
                because we have the "treat all warnings as errors" flag set above.
              -->
              <arg>-Xlint:-processing</arg>
            </compilerArgs>
            <showWarnings>true</showWarnings>
            <showDeprecation>true</showDeprecation>
          </configuration>
        </plugin>

        <!-- Release tags should be v<VERSION>. -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.5.1</version>
          <configuration>
            <tagNameFormat>v@{project.version}</tagNameFormat>
          </configuration>
        </plugin>

        <!-- Run checkstyle using the Google Java Style configuration. -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <version>2.17</version>
          <configuration>
            <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
            <includeTestSourceDirectory>true</includeTestSourceDirectory>
            <checkstyleRules>
              <!--
                  Checkstyle configuration that checks the Google coding conventions from:

                  -  Google Java Style
                     https://google-styleguide.googlecode.com/svn-history/r130/trunk/javaguide.html

                  Checkstyle is very configurable. Be sure to read the documentation at
                  http://checkstyle.sf.net (or in your downloaded distribution).

                  Most Checks are configurable, be sure to consult the documentation.

                  To completely disable a check, just comment it out or delete it from the file.

                  Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov.
               -->
              <module name="Checker">
                <property name="charset" value="UTF-8" />

                <property name="severity" value="warning" />

                <!-- Checks for whitespace                               -->
                <!-- See http://checkstyle.sf.net/config_whitespace.html -->
                <module name="FileTabCharacter">
                  <property name="eachLine" value="true" />
                </module>

                <module name="TreeWalker">
                  <module name="FileContentsHolder" />
                  <module name="OuterTypeFilename" />
                  <module name="IllegalTokenText">
                    <property name="tokens" value="STRING_LITERAL, CHAR_LITERAL" />
                    <property name="format" value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)" />
                    <property name="message" value="Avoid using corresponding octal or Unicode escape." />
                  </module>
                  <module name="AvoidEscapedUnicodeCharacters">
                    <property name="allowEscapesForControlCharacters" value="true" />
                    <property name="allowByTailComment" value="true" />
                    <property name="allowNonPrintableEscapes" value="true" />
                  </module>
                  <module name="LineLength">
                    <property name="max" value="100" />
                    <property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://" />
                  </module>
                  <module name="AvoidStarImport" />
                  <module name="OneTopLevelClass" />
                  <module name="NoLineWrap" />
                  <module name="EmptyBlock">
                    <property name="option" value="TEXT" />
                    <property name="tokens" value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH" />
                  </module>
                  <module name="NeedBraces" />
                  <module name="LeftCurly">
                    <property name="maxLineLength" value="100" />
                  </module>
                  <module name="RightCurly" />
                  <module name="RightCurly">
                    <property name="option" value="alone" />
                    <property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT" />
                  </module>
                  <module name="WhitespaceAround">
                    <property name="allowEmptyConstructors" value="true" />
                    <property name="allowEmptyMethods" value="true" />
                    <property name="allowEmptyTypes" value="true" />
                    <property name="allowEmptyLoops" value="true" />
                    <message key="ws.notFollowed" value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)" />
                    <message key="ws.notPreceded" value="WhitespaceAround: ''{0}'' is not preceded with whitespace." />
                  </module>
                  <module name="OneStatementPerLine" />
                  <module name="MultipleVariableDeclarations" />
                  <module name="ArrayTypeStyle" />
                  <module name="MissingSwitchDefault" />
                  <module name="FallThrough" />
                  <module name="UpperEll" />
                  <module name="ModifierOrder" />
                  <module name="EmptyLineSeparator">
                    <property name="allowNoEmptyLineBetweenFields" value="true" />
                  </module>
                  <module name="SeparatorWrap">
                    <property name="tokens" value="DOT" />
                    <property name="option" value="nl" />
                  </module>
                  <module name="SeparatorWrap">
                    <property name="tokens" value="COMMA" />
                    <property name="option" value="EOL" />
                  </module>
                  <module name="PackageName">
                    <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$" />
                    <message key="name.invalidPattern" value="Package name ''{0}'' must match pattern ''{1}''." />
                  </module>
                  <module name="TypeName">
                    <message key="name.invalidPattern" value="Type name ''{0}'' must match pattern ''{1}''." />
                  </module>
                  <module name="MemberName">
                    <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$" />
                    <message key="name.invalidPattern" value="Member name ''{0}'' must match pattern ''{1}''." />
                  </module>
                  <module name="ParameterName">
                    <property name="format" value="^[a-z][a-zA-Z0-9]*$" />
                    <message key="name.invalidPattern" value="Parameter name ''{0}'' must match pattern ''{1}''." />
                  </module>
                  <module name="LocalVariableName">
                    <property name="tokens" value="VARIABLE_DEF" />
                    <property name="format" value="^[a-z][a-zA-Z0-9]*$" />
                    <property name="allowOneCharVarInForLoop" value="true" />
                    <message key="name.invalidPattern" value="Local variable name ''{0}'' must match pattern ''{1}''." />
                  </module>
                  <module name="ClassTypeParameterName">
                    <property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)" />
                    <message key="name.invalidPattern" value="Class type name ''{0}'' must match pattern ''{1}''." />
                  </module>
                  <module name="MethodTypeParameterName">
                    <property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)" />
                    <message key="name.invalidPattern" value="Method type name ''{0}'' must match pattern ''{1}''." />
                  </module>
                  <module name="NoFinalizer" />
                  <module name="GenericWhitespace">
                    <message key="ws.followed" value="GenericWhitespace ''{0}'' is followed by whitespace." />
                    <message key="ws.preceded" value="GenericWhitespace ''{0}'' is preceded with whitespace." />
                    <message key="ws.illegalFollow" value="GenericWhitespace ''{0}'' should followed by whitespace." />
                    <message key="ws.notPreceded" value="GenericWhitespace ''{0}'' is not preceded with whitespace." />
                  </module>
                  <module name="Indentation">
                    <property name="basicOffset" value="2" />
                    <property name="braceAdjustment" value="0" />
                    <property name="caseIndent" value="2" />
                    <property name="throwsIndent" value="4" />
                    <property name="lineWrappingIndentation" value="4" />
                    <property name="arrayInitIndent" value="2" />
                  </module>
                  <module name="AbbreviationAsWordInName">
                    <property name="ignoreFinal" value="false" />
                    <property name="allowedAbbreviationLength" value="1" />
                    <property name="allowedAbbreviations" value="IT" />
                  </module>
                  <module name="OverloadMethodsDeclarationOrder" />
                  <module name="VariableDeclarationUsageDistance" />
                  <module name="ImportOrder" />
                  <module name="MethodParamPad" />
                  <module name="OperatorWrap">
                    <property name="option" value="NL" />
                    <property name="tokens" value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR " />
                  </module>
                  <module name="AnnotationLocation">
                    <property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF" />
                  </module>
                  <module name="AnnotationLocation">
                    <property name="tokens" value="VARIABLE_DEF" />
                    <property name="allowSamelineMultipleAnnotations" value="true" />
                  </module>
                  <module name="NonEmptyAtclauseDescription" />
                  <module name="JavadocTagContinuationIndentation" />
                  <module name="SummaryJavadocCheck">
                    <property name="forbiddenSummaryFragments" value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )" />
                  </module>
                  <module name="JavadocParagraph" />
                  <module name="AtclauseOrder">
                    <property name="tagOrder" value="@param, @return, @throws, @deprecated" />
                    <property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF" />
                  </module>
                  <module name="JavadocMethod">
                    <property name="scope" value="public" />
                    <property name="allowMissingParamTags" value="true" />
                    <property name="allowMissingThrowsTags" value="true" />
                    <property name="allowMissingReturnTag" value="true" />
                    <property name="minLineCount" value="2" />
                    <property name="allowedAnnotations" value="After, AfterClass, Before, BeforeClass, Override, Test" />
                    <property name="allowThrowsTagsForSubclasses" value="true" />
                  </module>
                  <module name="MethodName">
                    <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$" />
                    <message key="name.invalidPattern" value="Method name ''{0}'' must match pattern ''{1}''." />
                  </module>
                  <module name="SingleLineJavadoc" />
                </module>

                <module name="SuppressionCommentFilter" />
              </module>
            </checkstyleRules>
          </configuration>
          <executions>
            <execution>
              <phase>compile</phase>
              <goals>
                <goal>check</goal>
              </goals>
              <configuration>
                <violationSeverity>warning</violationSeverity>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>

    <!-- These plugins take effect only for this pom. -->
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
      </plugin>
    </plugins>

    <extensions>
      <!-- Publish everything to S3 instead of a maven repo. -->
      <extension>
        <groupId>com.mainstreethub.build</groupId>
        <artifactId>aws-maven</artifactId>
        <version>5.0.0.RELEASE.MSH.1</version>
      </extension>
    </extensions>
  </build>

  <profiles>
    <profile>
      <id>open-source</id>
      <build>
        <plugins>
          <!-- Publish artifacts to maven central instead of S3. -->
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <version>1.6.7</version>
            <extensions>true</extensions>
            <configuration>
              <serverId>oss.sonatype.org</serverId>
              <nexusUrl>https://oss.sonatype.org/</nexusUrl>
              <autoReleaseAfterClose>true</autoReleaseAfterClose>
            </configuration>
          </plugin>

          <!-- Sign artifacts with GPG. -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>1.6</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
