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

<!--
 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.

 Copyright © 2011-2012 ForgeRock AS. All rights reserved.

 The contents of this file are subject to the terms
 of the Common Development and Distribution License
 (the License). You may not use this file except in
 compliance with the License.

 You can obtain a copy of the License at
 http://forgerock.org/license/CDDLv1.0.html
 See the License for the specific language governing
 permission and limitations under the License.

 When distributing Covered Code, include this CDDL
 Header Notice in each file and include the License file
 at http://forgerock.org/license/CDDLv1.0.html
 If applicable, add the following below the CDDL Header,
 with the fields enclosed by brackets [] replaced by
 your own identifying information:
 "Portions Copyrighted [year] [name of copyright owner]"
-->

<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.forgerock</groupId>
    <artifactId>forgerock-parent</artifactId>
    <version>1.1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>ForgeRock Parent</name>
    <description>Parent POM for ForgeRock projects. Provides default project build configuration.</description>
    <url>http://www.forgerock.com</url>
    <licenses>
        <license>
            <name>CDDL-1.0</name>
            <url>http://www.opensource.org/licenses/cddl1.php</url>
            <comments>Common Development and Distribution License (CDDL) 1.0</comments>
            <distribution>repo</distribution>
        </license>
    </licenses>
    <organization>
        <name>ForgeRock AS</name>
        <url>http://www.forgerock.com</url>
    </organization>
    <issueManagement>
        <system>jira</system>
        <url>https://bugster.forgerock.org</url>
    </issueManagement>
    <scm>
        <connection>scm:svn:https://svn.forgerock.org/commons/forgerock-parent/trunk</connection>
        <developerConnection>scm:svn:https://svn.forgerock.org/commons/forgerock-parent/trunk</developerConnection>
        <url>http://sources.forgerock.org/browse/commons/forgerock-parent/trunk</url>
    </scm>
    <distributionManagement>
        <snapshotRepository>
            <id>forgerock-snapshots</id>
            <name>ForgeRock Snapshot Repository</name>
            <url>${forgerockDistMgmtSnapshotsUrl}</url>
        </snapshotRepository>
        <repository>
            <id>forgerock-staging</id>
            <name>ForgeRock Release Repository</name>
            <url>${forgerockDistMgmtReleasesUrl}</url>
        </repository>
    </distributionManagement>

    <!-- (see FAQ at http://maven.apache.org/guides/mini/guide-central-repository-upload.html ) -->
    <repositories>
        <repository>
            <id>forgerock-staging-repository</id>
            <name>ForgeRock Release Repository</name>
            <url>http://maven.forgerock.org/repo/releases</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <releases>
                <enabled>true</enabled>
            </releases>
        </repository>
        <repository>
            <id>forgerock-snapshots-repository</id>
            <name>ForgeRock Snapshot Repository</name>
            <url>http://maven.forgerock.org/repo/snapshots</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <releases>
                <enabled>false</enabled>
            </releases>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>forgerock-plugins-repository</id>
            <name>ForgeRock Plugin Repository</name>
            <url>http://maven.forgerock.org/repo/repo</url>
        </pluginRepository>
    </pluginRepositories>

    <properties>
        <!-- ************** -->
        <!-- Build settings -->
        <!-- ************** -->

        <!-- Cross plugins settings -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- maven-compiler-plugin -->
        <maven.compiler.target>1.5</maven.compiler.target>
        <maven.compiler.source>1.5</maven.compiler.source>

        <!-- maven-enforcer-plugin -->
        <maven.min.version>2.2.1</maven.min.version>
        <jdk.min.version>${maven.compiler.source}</jdk.min.version>

        <!-- maven-idea-plugin & maven-eclipse-plugin -->
        <downloadSources>true</downloadSources>
        <downloadJavadocs>true</downloadJavadocs>

        <!-- maven-pmd-plugin -->
        <targetJdk>${maven.compiler.target}</targetJdk>

        <!-- maven-checkstyle-plugin -->
        <checkstyleConfigLocation>config/sun_checks.xml</checkstyleConfigLocation>
        <!--checkstyleConfigLocation>${project.basedir}/src/checkstyle/checkstyle.xml</checkstyleConfigLocation-->

        <!-- ***************** -->
        <!-- Repository Deployment URLs -->
        <!-- ***************** -->
        <forgerockDistMgmtSnapshotsUrl>http://maven.forgerock.org/repo/snapshots</forgerockDistMgmtSnapshotsUrl>
        <forgerockDistMgmtReleasesUrl>http://maven.forgerock.org/repo/releases</forgerockDistMgmtReleasesUrl>

        <!-- this property makes sure NetBeans 6.8+ picks up some formatting rules from checkstyle -->
        <netbeans.checkstyle.format>true</netbeans.checkstyle.format>
    </properties>

    <build>
        <pluginManagement>
            <!--    mvn versions:display-plugin-updates
                    mvn versions:display-dependency-updates
                    mvn versions:use-latest-versions
            -->
            <plugins>
                <!-- set versions of common plugins for reproducibility, ordered alphabetically -->
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>cobertura-maven-plugin</artifactId>
                    <version>2.5.1</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>findbugs-maven-plugin</artifactId>
                    <version>2.3.3</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>1.7</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>2.2.2</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-bundle-plugin</artifactId>
                    <version>2.3.7</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-checkstyle-plugin</artifactId>
                    <version>2.8</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>2.4.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.3.2</version>
                    <configuration>
                        <source>${maven.compiler.target}</source>
                        <target>${maven.compiler.target}</target>
                        <encoding>${project.build.sourceEncoding}</encoding>
                        <compilerArgument>-Xlint:all</compilerArgument>
                        <showWarnings>true</showWarnings>
                        <showDeprecation>true</showDeprecation>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>2.4</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>2.7</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-docck-plugin</artifactId>
                    <version>1.0</version>
                </plugin>
                <!-- http://jira.codehaus.org/browse/MECLIPSE-642 -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-eclipse-plugin</artifactId>
                    <version>2.7</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>1.0.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>1.4</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>2.3.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-invoker-plugin</artifactId>
                    <version>1.5</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>2.3.2</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jarsigner-plugin</artifactId>
                    <version>1.2</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>2.8</version>
                    <configuration>
                        <author>false</author>
                        <quiet>true</quiet>
                        <header><![CDATA[<b>${project.name} ${project.version}</b>]]>
                        </header>
                        <footer><![CDATA[<b>${project.name} ${project.version}</b>]]>
                        </footer>
                        <additionalparam>-linksource</additionalparam>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-plugin-plugin</artifactId>
                    <version>2.9</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-pmd-plugin</artifactId>
                    <version>2.6</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-project-info-reports-plugin</artifactId>
                    <version>2.4</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>2.2.2</version>
                    <configuration>
                        <mavenExecutorId>forked-path</mavenExecutorId>
                        <useReleaseProfile>false</useReleaseProfile>
                        <suppressCommitBeforeTag>true</suppressCommitBeforeTag>
                        <goals>deploy</goals>
                        <arguments>-Pforgerock-release</arguments>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-remote-resources-plugin</artifactId>
                    <version>1.2.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.5</version>
                    <configuration>
                        <encoding>${project.build.sourceEncoding}</encoding>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-scm-plugin</artifactId>
                    <version>1.6</version>
                    <configuration>
                        <tag>${project.artifactId}-${project.version}</tag>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>1.5</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>3.0</version>
                    <configuration>
                        <outputEncoding>${project.build.sourceEncoding}</outputEncoding>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>org.apache.maven.wagon</groupId>
                            <artifactId>wagon-ssh</artifactId>
                            <version>2.2</version>
                        </dependency>
                    </dependencies>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>2.1.2</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.11</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.1.1</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.plexus</groupId>
                    <artifactId>plexus-maven-plugin</artifactId>
                    <version>1.3.8</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <id>enforce</id>
            <activation>
                <property>
                    <name>!skip-enforce</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-enforcer-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>enforce-plugin-versions</id>
                                <goals>
                                    <goal>enforce</goal>
                                </goals>
                                <configuration>
                                    <rules>
                                        <requirePluginVersions>
                                            <message>Best practice is to always define plugin versions!</message>
                                            <banLatest>true</banLatest>
                                            <banRelease>true</banRelease>
                                            <phases>deploy,site</phases>
                                        </requirePluginVersions>
                                    </rules>
                                </configuration>
                            </execution>
                            <execution>
                                <id>enforce-java-version</id>
                                <goals>
                                    <goal>enforce</goal>
                                </goals>
                                <configuration>
                                    <rules>
                                        <requireJavaVersion>
                                            <message>To build this project JDK ${jdk.min.version} (or greater) is required. Please install it.</message>
                                            <version>${jdk.min.version}</version>
                                        </requireJavaVersion>
                                    </rules>
                                </configuration>
                            </execution>
                            <execution>
                                <id>enforce-maven-version</id>
                                <goals>
                                    <goal>enforce</goal>
                                </goals>
                                <configuration>
                                    <rules>
                                        <requireMavenVersion>
                                            <message>To build this project Maven ${maven.min.version} (or greater) is required. Please install it.</message>
                                            <version>${maven.min.version}</version>
                                        </requireMavenVersion>
                                    </rules>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>metrics</id>
            <properties>
                <testReportsDirectory>${project.build.directory}/surefire-reports/cobertura</testReportsDirectory>
            </properties>
            <build>
                <plugins>
                    <!-- Cobertura -->
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>cobertura-maven-plugin</artifactId>
                        <configuration>
                            <formats>
                                <format>xml</format>
                                <format>html</format>
                            </formats>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>cobertura</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>

            <reporting>
                <plugins>
                    <!-- FindBugs -->
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>findbugs-maven-plugin</artifactId>
                        <configuration>
                            <xmlOutput>true</xmlOutput>
                            <findbugsXmlOutput>true</findbugsXmlOutput>
                            <findbugsXmlWithMessages>true</findbugsXmlWithMessages>
                            <effort>Max</effort>
                            <threshold>Low</threshold>
                            <failOnError>false</failOnError>
                        </configuration>
                    </plugin>

                    <!-- PMD -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-pmd-plugin</artifactId>
                        <configuration>
                            <linkXref>true</linkXref>
                            <sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
                            <minimumTokens>100</minimumTokens>
                        </configuration>
                    </plugin>

                    <!-- CheckStyle -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-checkstyle-plugin</artifactId>
                        <!--dependencies>
                            <dependency>
                                <groupId>org.forgerock.commons</groupId>
                                <artifactId>forgerock-checkstyle-checks</artifactId>
                                <version>1.0.0-SNAPSHOT</version>
                            </dependency>
                        </dependencies-->
                        <configuration>
                            <configLocation>${checkstyleConfigLocation}</configLocation>
                        </configuration>
                    </plugin>
                </plugins>
            </reporting>
        </profile>
        <profile>
            <id>sign</id>
            <build>
                <plugins>
                    <!-- We want to sign the artifact, the POM, and all attached artifacts -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <configuration>
                            <passphrase>${gpg.passphrase}</passphrase>
                            <useAgent>true</useAgent>
                        </configuration>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>                    
                </plugins>
            </build>
        </profile>
        <profile>
            <id>forgerock-release</id>
            <build>
                <plugins>
                    <plugin>
                        <inherited>true</inherited>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-deploy-plugin</artifactId>
                        <configuration>
                            <updateReleaseInfo>true</updateReleaseInfo>
                        </configuration>
                    </plugin>
                    <!-- Publish also javasources when releasing - required -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- Publish also javadocs when releasing - required -->
                    <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>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-enforcer-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>enforce-maven</id>
                                <goals>
                                    <goal>enforce</goal>
                                </goals>
                                <configuration>
                                    <rules>
                                        <requireMavenVersion>
                                            <version>(,2.1.0),(2.1.0,2.2.0),(2.2.0,)</version>
                                            <message>Maven 2.1.0 and 2.2.0 produce incorrect GPG signatures and checksums respectively.</message>
                                        </requireMavenVersion>
                                    </rules>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>maven-3</id>
            <activation>
                <file>
                    <!--  This employs that the basedir expression is only recognized by Maven 3.x (see MNG-2363) -->
                    <exists>${basedir}</exists>
                </file>
            </activation>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-site-plugin</artifactId>
                            <configuration>
                                <outputEncoding>${project.build.sourceEncoding}</outputEncoding>
                            </configuration>
                        </plugin>
                    </plugins>
                </pluginManagement>
                <plugins>
                    <!-- if releasing current pom with maven 3 site descriptor must be attached -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-site-plugin</artifactId>
                        <inherited>false</inherited>
                        <executions>
                            <execution>
                                <id>attach-descriptor</id>
                                <goals>
                                    <goal>attach-descriptor</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

