<?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>6</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-6</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>
        <project.build.targetJdk>1.7</project.build.targetJdk>
        <basepom.build.jvmsize>1024m</basepom.build.jvmsize>
        <basepom.maven.version>3.3.3</basepom.maven.version>

        <!-- Plugin versions from foundation -->
        <dep.plugin.clean.version>3.0.0</dep.plugin.clean.version>
        <dep.plugin.compiler.version>3.5.1</dep.plugin.compiler.version>
        <dep.plugin.deploy.version>2.8.2</dep.plugin.deploy.version>
        <dep.plugin.install.version>2.5.2</dep.plugin.install.version>
        <dep.plugin.resources.version>2.7</dep.plugin.resources.version>
        <dep.plugin.jar.version>2.6</dep.plugin.jar.version>
        <dep.plugin.shade.version>2.4.3</dep.plugin.shade.version>
        <dep.plugin.javadoc.version>2.10.3</dep.plugin.javadoc.version>
        <dep.plugin.dependency.version>2.10</dep.plugin.dependency.version>
        <dep.plugin.enforcer.version>1.4.1</dep.plugin.enforcer.version>
        <dep.plugin.release.version>2.5.3</dep.plugin.release.version>
        <dep.plugin.scm.version>1.9.4</dep.plugin.scm.version>
        <dep.plugin.toolchains.version>1.1</dep.plugin.toolchains.version>

        <!-- Plugin versions from oss -->
        <dep.plugin.gpg.version>1.6</dep.plugin.gpg.version>
        <dep.plugin.license.version>2.11</dep.plugin.license.version>

        <dep.findbugs.version>3.0.1</dep.findbugs.version>
    </properties>

    <prerequisites>
        <maven>${basepom.maven.version}</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>

    <dependencies>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>${dep.plugin.shade.version}</version>
            <scope>provided</scope>
            <optional>true</optional>
            <exclusions>
                <exclusion>
                    <groupId>*</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>annotations</artifactId>
            <version>${dep.findbugs.version}</version>
            <optional>true</optional>
        </dependency>
    </dependencies>

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

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>${dep.plugin.enforcer.version}</version>
                    <configuration>
                        <fail>true</fail>
                        <failFast>false</failFast>
                        <rules>
                            <requireMavenVersion>
                                <version>[${basepom.maven.version},)</version>
                            </requireMavenVersion>
                            <requireJavaVersion>
                                <version>${project.build.targetJdk}</version>
                            </requireJavaVersion>
                        </rules>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>${dep.plugin.dependency.version}</version>
                    <configuration>
                        <skip>${basepom.check.skip-dependency}</skip>
                        <failOnWarning>${basepom.check.fail-dependency}</failOnWarning>
                        <ignoreNonCompile>true</ignoreNonCompile>
                    </configuration>
                </plugin>

                <!-- Tweak the compiler to use more memory and use UTF-8 for the source code. -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${dep.plugin.compiler.version}</version>
                    <configuration>
                        <source>${project.build.targetJdk}</source>
                        <target>${project.build.targetJdk}</target>
                        <encoding>${project.build.sourceEncoding}</encoding>
                        <maxmem>${basepom.build.jvmsize}</maxmem>
                        <showWarnings>true</showWarnings>
                        <compilerArguments>
                            <Werror />
                        </compilerArguments>
                    </configuration>
                </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>
                            <manifestEntries>
                                <X-BasePOM-Build-Id>${basepom.build.id}</X-BasePOM-Build-Id>
                                <X-BasePOM-Name>${project.name}</X-BasePOM-Name>
                                <X-BasePOM-Git-Commit-Id>${git.commit.id}</X-BasePOM-Git-Commit-Id>
                            </manifestEntries>
                            <manifestSections combine.children="append">
                                <manifestSection>
                                    <name>${project.groupId}:${project.artifactId}</name>
                                    <manifestEntries>
                                        <!-- This is actually the time when the build was done -->
                                        <Build-Time>${git.build.time}</Build-Time>
                                        <!-- Git specific properties -->
                                        <Git-Branch>${git.branch}</Git-Branch>
                                        <Git-Commit-Id>${git.commit.id}</Git-Commit-Id>
                                        <Git-Commit-Id-Describe>${git.commit.id.describe}</Git-Commit-Id-Describe>
                                        <Git-Remote-Origin-Url>${git.remote.origin.url}</Git-Remote-Origin-Url>
                                        <!-- project information -->
                                        <Project-ArtifactId>${project.artifactId}</Project-ArtifactId>
                                        <Project-GroupId>${project.groupId}</Project-GroupId>
                                        <Project-Name>${project.name}</Project-Name>
                                        <Project-Version>${project.version}</Project-Version>
                                    </manifestEntries>
                                </manifestSection>
                            </manifestSections>
                        </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>
                            <yaml>SCRIPT_STYLE</yaml>
                        </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-javadoc-plugin</artifactId>
                    <version>${dep.plugin.javadoc.version}</version>
                    <configuration>
                        <source>${project.build.targetJdk}</source>
                        <target>${project.build.targetJdk}</target>
                        <encoding>${project.build.sourceEncoding}</encoding>
                        <maxmemory>${basepom.build.jvmsize}</maxmemory>
                        <additionalparam>-quiet</additionalparam>
                    </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>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-toolchains-plugin</artifactId>
                    <version>${dep.plugin.toolchains.version}</version>
                    <configuration>
                        <toolchains>
                            <jdk>
                                <version>${project.build.targetJdk}</version>
                                <vendor>oracle</vendor>
                            </jdk>
                        </toolchains>
                    </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>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-toolchains-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>toolchain</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>
