<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright (c) 2009-present the original author or authors.

    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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.planet57.buildsupport</groupId>
  <artifactId>buildsupport</artifactId>
  <name>${project.groupId}:${project.artifactId}</name>
  <packaging>pom</packaging>

  <version>2</version>

  <description>
    Common build configuration.
  </description>

  <url>http://planet57.com/</url>

  <licenses>
    <license>
      <name>ASL2</name>
      <url>http://opensource.org/licenses/Apache-2.0</url>
    </license>
  </licenses>

  <scm>
    <url>https://github.com/jdillon/buildsupport</url>
    <connection>scm:git:git://github.com/jdillon/buildsupport.git</connection>
    <developerConnection>scm:git:git@github.com:jdillon/buildsupport.git</developerConnection>
  </scm>

  <developers>
    <developer>
      <id>jdillon</id>
      <name>Jason Dillon</name>
      <email>jason@planet57.com</email>
    </developer>
  </developers>

  <prerequisites>
    <maven>3.3.3</maven>
  </prerequisites>

  <properties>
    <!--
    Define buildsupport version, this value must always be a constant
    -->
    <buildsupport.version>2</buildsupport.version>

    <!--
    File encodings.
    -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

    <!--
    Build timestamp.
    -->
    <maven.build.timestamp.format>yyyyMMddHHmm</maven.build.timestamp.format>
    <build.timestamp>${maven.build.timestamp}</build.timestamp>

    <!--
    Test defaults.
    -->
    <maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>
    <surefire.failIfNoSpecifiedTests>false</surefire.failIfNoSpecifiedTests>
    <failsafe.timeout>600</failsafe.timeout>
    <it.failIfNoSpecifiedTests>false</it.failIfNoSpecifiedTests>

    <!--
    Compiler defaults.
    -->
    <maven.compiler.source>1.6</maven.compiler.source>
    <maven.compiler.target>1.6</maven.compiler.target>

    <!--
    Deployment configuration.
    -->
    <deployAtEnd>true</deployAtEnd>

    <public.serverId>ossrh</public.serverId>
    <public.nexusUrl>https://oss.sonatype.org</public.nexusUrl>

    <public-release.serverId>${public.serverId}</public-release.serverId>
    <public-release.url>https://oss.sonatype.org/service/local/staging/deploy/maven2</public-release.url>

    <public-snapshot.serverId>${public.serverId}</public-snapshot.serverId>
    <public-snapshot.url>https://oss.sonatype.org/content/repositories/snapshots</public-snapshot.url>

    <!--
    Staging configuration.
    -->
    <staging.serverId>${public.serverId}</staging.serverId>
    <staging.nexusUrl>${public.nexusUrl}</staging.nexusUrl>
    <staging.progressTimeout>15</staging.progressTimeout>
  </properties>

  <repositories>
    <!-- variables are apparently unhappy to be used in id/url elements -->
    <repository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

  <distributionManagement>
    <repository>
      <id>${public-release.serverId}</id>
      <url>${public-release.url}</url>
    </repository>

    <snapshotRepository>
      <id>${public-snapshot.serverId}</id>
      <url>${public-snapshot.url}</url>
    </snapshotRepository>
  </distributionManagement>

  <modules>
    <module>public-parent</module>
  </modules>

  <build>
    <defaultGoal>install</defaultGoal>

    <resources>
      <resource>
        <directory>${project.basedir}/src/main/resources</directory>
        <filtering>false</filtering>
        <includes>
          <include>**/*</include>
        </includes>
      </resource>

      <resource>
        <directory>${project.basedir}/src/main/filtered-resources</directory>
        <filtering>true</filtering>
        <includes>
          <include>**/*</include>
        </includes>
      </resource>
    </resources>

    <testResources>
      <testResource>
        <directory>${project.basedir}/src/test/resources</directory>
        <filtering>false</filtering>
        <includes>
          <include>**/*</include>
        </includes>
      </testResource>

      <testResource>
        <directory>${project.basedir}/src/test/filtered-resources</directory>
        <filtering>true</filtering>
        <includes>
          <include>**/*</include>
        </includes>
      </testResource>
    </testResources>

    <!--
    Plugin defaults.
    -->
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.8</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>3.0.0</version>
          <configuration>
            <tarLongFileMode>posix</tarLongFileMode>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.6.1</version>
          <configuration>
            <source>${maven.compiler.source}</source>
            <target>${maven.compiler.target}</target>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-enforcer-plugin</artifactId>
          <version>1.4.1</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-gpg-plugin</artifactId>
          <version>1.6</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-invoker-plugin</artifactId>
          <version>2.0.0</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.0.2</version>
          <configuration>
            <archive>
              <manifest>
                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
              </manifest>
            </archive>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>2.10.4</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-plugin-plugin</artifactId>
          <version>3.5</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.5.3</version>
          <configuration>
            <localCheckout>true</localCheckout>
            <pushChanges>false</pushChanges>
            <autoVersionSubmodules>true</autoVersionSubmodules>
            <goals>deploy</goals>
            <mavenExecutorId>forked-path</mavenExecutorId>
            <releaseProfiles>buildsupport-release</releaseProfiles>
            <useReleaseProfile>false</useReleaseProfile>
            <tagNameFormat>release-@{project.version}</tagNameFormat>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-remote-resources-plugin</artifactId>
          <version>1.5</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-repository-plugin</artifactId>
          <version>2.4</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-scm-plugin</artifactId>
          <version>1.9.5</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-shade-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-site-plugin</artifactId>
          <version>3.6</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>3.0.1</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.20</version>
          <configuration>
            <forkMode>once</forkMode>
            <redirectTestOutputToFile>${maven.test.redirectTestOutputToFile}</redirectTestOutputToFile>
            <failIfNoSpecifiedTests>${surefire.failIfNoSpecifiedTests}</failIfNoSpecifiedTests>
            <systemPropertyVariables>
              <java.awt.headless>true</java.awt.headless>
              <java.io.tmpdir>${java.io.tmpdir}</java.io.tmpdir>
            </systemPropertyVariables>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>2.20</version>
          <configuration>
            <forkMode>always</forkMode>
            <redirectTestOutputToFile>${maven.test.redirectTestOutputToFile}</redirectTestOutputToFile>
            <failIfNoSpecifiedTests>${it.failIfNoSpecifiedTests}</failIfNoSpecifiedTests>
            <forkedProcessTimeoutInSeconds>${failsafe.timeout}</forkedProcessTimeoutInSeconds>
            <systemPropertyVariables>
              <java.awt.headless>true</java.awt.headless>
              <java.io.tmpdir>${java.io.tmpdir}</java.io.tmpdir>
            </systemPropertyVariables>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-war-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>

        <plugin>
          <groupId>org.apache.felix</groupId>
          <artifactId>maven-bundle-plugin</artifactId>
          <version>3.3.0</version>
          <configuration>
            <instructions>
              <Bundle-Description>${project.description}</Bundle-Description>
            </instructions>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.codehaus.modello</groupId>
          <artifactId>modello-maven-plugin</artifactId>
          <version>1.9.1</version>
          <configuration>
            <useJava5>true</useJava5>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>animal-sniffer-maven-plugin</artifactId>
          <version>1.15</version>
        </plugin>

        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>

        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>buildnumber-maven-plugin</artifactId>
          <version>1.4</version>
        </plugin>

        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>exec-maven-plugin</artifactId>
          <version>1.6.0</version>
        </plugin>

        <plugin>
          <groupId>org.eclipse.sisu</groupId>
          <artifactId>sisu-maven-plugin</artifactId>
          <version>0.3.3</version>
        </plugin>

        <!--
        See 'license-check' and 'license-format' profiles.
        -->
        <plugin>
          <groupId>com.mycila</groupId>
          <artifactId>license-maven-plugin</artifactId>
          <version>3.0</version>
          <configuration>
            <encoding>UTF-8</encoding>
            <strictCheck>true</strictCheck>
            <useDefaultExcludes>false</useDefaultExcludes>
            <header>${project.basedir}/header.txt</header>
            <aggregate>true</aggregate>
            <includes>
              <include>**/pom.xml</include>
              <include>**/*.xml</include>
              <include>**/*.xsd</include>
              <include>**/*.xjb</include>
              <include>**/*.properties</include>
              <include>**/*.ini</include>
              <include>**/*.java</include>
              <include>**/*.groovy</include>
              <include>**/*.scala</include>
              <include>**/*.aj</include>
              <include>**/*.js</include>
              <include>**/*.css</include>
              <include>**/*.help</include>
              <include>**/*.proto</include>
              <include>**/*.sm</include>
              <include>**/*.bat</include>
              <include>**/*.xsl</include>
              <include>**/*.html</include>
              <include>**/*.vm</include>
              <include>**/*.md</include>
              <include>**/*.sh</include>
              <include>**/*.bash</include>
              <include>**/*.rb</include>
            </includes>
            <excludes>
              <exclude>**/target/**</exclude>
              <exclude>**/.*/**</exclude>
              <exclude>**/dependency-reduced-pom.xml</exclude>
              <exclude>**/nbactions*.xml</exclude>
              <exclude>**/nb-configuration.xml</exclude>
              <exclude>**/atlassian-ide-plugin.xml</exclude>
              <exclude>**/release.properties</exclude>
              <exclude>**/META-INF/services/**</exclude>
            </excludes>
            <mapping>
              <aj>JAVADOC_STYLE</aj>
              <groovy>SLASHSTAR_STYLE</groovy>
              <help>SCRIPT_STYLE</help>
              <ini>SCRIPT_STYLE</ini>
              <java>SLASHSTAR_STYLE</java>
              <md>XML_STYLE</md>
              <proto>DOUBLESLASH_STYLE</proto>
              <scala>SLASHSTAR_STYLE</scala>
              <sm>DOUBLESLASH_STYLE</sm>
              <vm>VELOCITY_STYLE</vm>
              <xjb>XML_STYLE</xjb>
            </mapping>
          </configuration>
        </plugin>

        <!--
        Enhanced deployment configuration.  See 'buildsupport-staging' profile to disable.
        -->
        <plugin>
          <groupId>org.sonatype.plugins</groupId>
          <artifactId>nexus-staging-maven-plugin</artifactId>
          <version>1.6.8</version>
          <extensions>true</extensions>
          <configuration>
            <nexusUrl>${staging.nexusUrl}</nexusUrl>
            <serverId>${staging.serverId}</serverId>
            <altStagingDirectory>${staging.directory}</altStagingDirectory>
            <keepStagingRepositoryOnCloseRuleFailure>true</keepStagingRepositoryOnCloseRuleFailure>
            <stagingProgressTimeoutMinutes>${staging.progressTimeout}</stagingProgressTimeoutMinutes>
            <tags>
              <localUsername>${user.name}</localUsername>
              <javaVersion>${java.version}</javaVersion>
            </tags>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <profiles>
    <!--
    Allow disabling of source-jar generation.
    -->
    <profile>
      <id>buildsupport-sources</id>
      <activation>
        <property>
          <name>!buildsupport-sources.skip</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
              <execution>
                <goals>
                  <goal>jar-no-fork</goal>
                </goals>
                <configuration>
                  <includePom>true</includePom>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!--
    Allow disabling of staging integration.
    -->
    <profile>
      <id>buildsupport-staging</id>
      <activation>
        <property>
          <name>!buildsupport-staging.skip</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!--
    Java8 specific workarounds.
    -->
    <profile>
      <id>buildsupport-java8</id>
      <activation>
        <jdk>[1.8,)</jdk>
      </activation>

      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-javadoc-plugin</artifactId>
              <configuration>
                <!-- Turn off strict javadoc checks in Java-8 -->
                <additionalparam>-Xdoclint:none</additionalparam>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>

    <!--
    Release configuration.
    -->
    <profile>
      <id>buildsupport-release</id>
      <build>
        <!--
        Configure deployment plugins in DM so buildsupport-staging profile can disable advanced deployment to nexus.
        -->
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-deploy-plugin</artifactId>
              <configuration>
                <updateReleaseInfo>true</updateReleaseInfo>
              </configuration>
            </plugin>

            <plugin>
              <groupId>org.sonatype.plugins</groupId>
              <artifactId>nexus-staging-maven-plugin</artifactId>
              <configuration>
                <updateReleaseInfo>true</updateReleaseInfo>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>

        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-enforcer-plugin</artifactId>
            <executions>
              <execution>
                <id>enforce-release</id>
                <goals>
                  <goal>enforce</goal>
                </goals>
                <configuration>
                  <rules>
                    <!--
                    Disallow SNAPSHOT dependencies.
                    -->
                    <requireReleaseDeps>
                      <searchTransitive>true</searchTransitive>
                      <failWhenParentIsSnapshot>true</failWhenParentIsSnapshot>
                    </requireReleaseDeps>

                    <!--
                    Disallow SNAPSHOT, RELEASE, LATEST or pinned-SNAPSHOT plugins.
                    -->
                    <requirePluginVersions>
                      <banSnapshots>true</banSnapshots>
                      <banRelease>true</banRelease>
                      <banLatest>true</banLatest>
                      <banTimestamps>true</banTimestamps>
                    </requirePluginVersions>
                  </rules>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <configuration>
              <passphrase>${gpg.passphrase}</passphrase>
              <useAgent>true</useAgent>
            </configuration>
            <executions>
              <execution>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!--
    Verify license headers; use: mvn -Plicense-check -N
    -->
    <profile>
      <id>license-check</id>
      <build>
        <defaultGoal>com.mycila:license-maven-plugin:check</defaultGoal>
      </build>
    </profile>

    <!--
    Format license headers; use: mvn -Plicense-format -N
    -->
    <profile>
      <id>license-format</id>
      <build>
        <defaultGoal>com.mycila:license-maven-plugin:format</defaultGoal>
      </build>
    </profile>
  </profiles>

</project>
