<?xml version="1.0" encoding="utf-8"?>
<!--
~   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>org.basepom</groupId>
  <artifactId>basepom-policy</artifactId>
  <packaging>jar</packaging>
  <version>2</version>
  <name>basepom-policy</name>
  <description>
    Minimum set of policy applied by the basepom code.
  </description>

  <url>https://github.com/basepom/basepom-policy/</url>
  <inceptionYear>2013</inceptionYear>

  <scm>
    <connection>scm:git:git://github.com/basepom/basepom-policy.git</connection>
    <developerConnection>scm:git:git@github.com:basepom/basepom-policy.git</developerConnection>
    <url>https://github.com/basepom/basepom-policy</url>
    <tag>basepom-policy-2</tag>
  </scm>

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

  <developers>
    <developer>
      <id>hgschmie</id>
      <name>Henning Schmiedehausen</name>
      <email>henning@schmiedehausen.org</email>
      <timezone>-8</timezone>
    </developer>
  </developers>

  <properties>
    <!-- see http://docs.codehaus.org/display/MAVENUSER/POM+Element+for+Source+File+Encoding -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <!-- Plugin versions -->
    <dep.plugin.clean.version>2.5</dep.plugin.clean.version>
    <dep.plugin.deploy.version>2.8.1</dep.plugin.deploy.version>
    <dep.plugin.gpg.version>1.4</dep.plugin.gpg.version>
    <dep.plugin.install.version>2.5.1</dep.plugin.install.version>
    <dep.plugin.jar.version>2.4</dep.plugin.jar.version>
    <dep.plugin.license.version>2.5</dep.plugin.license.version>
    <dep.plugin.release.version>2.4.2</dep.plugin.release.version>
    <dep.plugin.resources.version>2.6</dep.plugin.resources.version>
    <dep.plugin.scm.version>1.9</dep.plugin.scm.version>
  </properties>

  <prerequisites>
    <maven>3.0.5</maven>
  </prerequisites>

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

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-scm-plugin</artifactId>
          <version>${dep.plugin.scm.version}</version>
          <configuration>
            <connectionType>developerConnection</connectionType>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>${dep.plugin.deploy.version}</version>
        </plugin>
        <!--  -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-clean-plugin</artifactId>
          <version>${dep.plugin.clean.version}</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-install-plugin</artifactId>
          <version>${dep.plugin.install.version}</version>
        </plugin>

        <!-- Resource plugins should always use UTF-8 -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>${dep.plugin.resources.version}</version>
          <configuration>
            <encoding>${project.build.sourceEncoding}</encoding>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-release-plugin</artifactId>
          <version>${dep.plugin.release.version}</version>
          <configuration>
            <releaseProfiles>oss-release</releaseProfiles>
            <autoVersionSubmodules>true</autoVersionSubmodules>
            <mavenExecutorId>forked-path</mavenExecutorId>
            <pushChanges>false</pushChanges>
            <localCheckout>true</localCheckout>
            <preparationGoals>clean install</preparationGoals>
            <useReleaseProfile>false</useReleaseProfile>
            <goals>deploy</goals>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>${dep.plugin.jar.version}</version>
          <configuration>
            <!-- do not build an empty jar if the project is
                 e.g. a pom project -->
            <skipIfEmpty>true</skipIfEmpty>
            <archive>
              <manifest>
                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                <addClasspath>false</addClasspath>
              </manifest>
            </archive>
          </configuration>
        </plugin>

        <plugin>
          <groupId>com.mycila</groupId>
          <artifactId>license-maven-plugin</artifactId>
          <version>${dep.plugin.license.version}</version>
          <configuration>
            <skip>false</skip>
            <skipExistingHeaders>false</skipExistingHeaders>
            <failIfMissing>true</failIfMissing>
            <header>${project.basedir}/src/main/resources/license/basepom-apache-license-header.txt</header>
            <headerDefinitions>
              <headerDefinition>${project.basedir}/src/main/resources/license/xml-prefix.xml</headerDefinition>
            </headerDefinitions>
            <mapping>
              <java>SLASHSTAR_STYLE</java>
              <xml>XML_PREFIX</xml>
            </mapping>
            <strictCheck>true</strictCheck>
            <aggregate>true</aggregate>
            <useDefaultExcludes>true</useDefaultExcludes>
            <encoding>${project.build.sourceEncoding}</encoding>
            <excludes>
              <exclude>.*/**</exclude>
              <exclude>**/*.md</exclude>
              <exclude>**/*.sh</exclude>
              <exclude>**/*.txt</exclude>
              <exclude>**/*.thrift</exclude>
              <exclude>**/*.proto</exclude>
              <exclude>**/*.g</exclude>
              <exclude>**/*.releaseBackup</exclude>
              <exclude>**/*.vm</exclude>
              <exclude>**/*.st</exclude>
              <exclude>**/*.raw</exclude>
              <exclude>**/*.ser</exclude>
              <exclude>**/src/license/**</exclude>
            </excludes>
            <includes>
              <include>src/**</include>
              <include>**/pom.xml</include>
            </includes>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-gpg-plugin</artifactId>
          <version>${dep.plugin.gpg.version}</version>
          <configuration>
            <useAgent>true</useAgent>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>

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

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

      <plugin>
        <groupId>com.mycila</groupId>
        <artifactId>license-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>default</id>
            <phase>verify</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>oss-release</id>
      <properties>
        <!-- tests run in the preparation step of the release -->
        <skipTests>true</skipTests>
      </properties>
      <build>
        <plugins>
          <!-- oss requires a javadoc jar. Build one when releasing. -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <phase>package</phase>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <!-- Sign artifacts using gpg for oss upload -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
