<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to Jive Communications Inc. under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  Jive Communications Inc. licenses this file to You 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>com.jive.foss</groupId>
  <artifactId>foss-parent</artifactId>
  <version>2</version>

  <inceptionYear>2015</inceptionYear>

  <packaging>pom</packaging>

  <name>Jive OSS Parent</name>
  <description>Jive's Open Source Project Parent</description>
  <url>https://jive.com</url>

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

  <developers>
    <!-- Required developers section -->
    <developer>
      <email>developers@jive.com</email>
      <name>Jive Developers</name>
      <id>developers</id>
    </developer>
  </developers>

  <properties>
    <!-- ##### Configuration for Java versions ##### -->
    <!-- Base Java Version for all of Jive, if not overridden on a specific project. -->
    <java.version.target>1.8</java.version.target>
    <java.version.source>1.8</java.version.source>

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

    <deps.awaitility.version>1.6.0</deps.awaitility.version>
    <deps.findbugs.version>2.0.3</deps.findbugs.version>
    <deps.guava.version>18.0</deps.guava.version>
    <deps.hawtdispatch.version>1.21</deps.hawtdispatch.version>
    <deps.junit4.version>4.11</deps.junit4.version>
    <deps.logback.version>1.1.1</deps.logback.version>
    <deps.lombok.version>1.16.2</deps.lombok.version>
    <deps.mockito.version>1.10.19</deps.mockito.version>
    <deps.objenesis.version>2.1</deps.objenesis.version>
    <deps.slf4j.version>1.7.7</deps.slf4j.version>

    <!-- Surefire and Failsafe share versions, use the same version for both -->
    <plugins.test-plugin.version>2.18.1</plugins.test-plugin.version>
  </properties>

  <scm>
    <connection>scm:git:ssh://git@github.com/jive/com.jive.foss.parent.git</connection>
    <developerConnection>scm:git:ssh://git@github.com/jive/com.jive.foss.parent.git</developerConnection>
    <url>https://github.com/jive/com.jive.foss.parent</url>
    <tag>2</tag>
  </scm>

  <distributionManagement>
    <repository>
      <id>oss.sonatype.org-releases</id>
      <name>Sonatype OSS Releases</name>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
    </repository>

    <snapshotRepository>
      <id>oss.sonatype.org-snapshots</id>
      <name>Sonatype OSS Snapshots</name>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
      <uniqueVersion>false</uniqueVersion>
    </snapshotRepository>
  </distributionManagement>

  <dependencyManagement>
    <dependencies>

      <dependency>
        <groupId>com.google.code.findbugs</groupId>
        <artifactId>jsr305</artifactId>
        <version>${deps.findbugs.version}</version>
      </dependency>

      <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>${deps.guava.version}</version>
      </dependency>

      <dependency>
        <groupId>com.jayway.awaitility</groupId>
        <artifactId>awaitility</artifactId>
        <version>${deps.awaitility.version}</version>
        <scope>test</scope>
      </dependency>

      <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>${deps.logback.version}</version>
        <scope>test</scope>
      </dependency>

      <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</artifactId>
        <version>${deps.logback.version}</version>
        <scope>test</scope>
      </dependency>

      <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${deps.junit4.version}</version>
        <scope>test</scope>
      </dependency>

      <dependency>
        <groupId>org.fusesource.hawtdispatch</groupId>
        <artifactId>hawtdispatch</artifactId>
        <version>${deps.hawtdispatch.version}</version>
      </dependency>

      <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-core</artifactId>
        <version>${deps.mockito.version}</version>
        <scope>test</scope>
        <exclusions>
          <exclusion>
            <artifactId>hamcrest-core</artifactId>
            <groupId>org.hamcrest</groupId>
          </exclusion>
        </exclusions>
      </dependency>

      <dependency>
        <groupId>org.objenesis</groupId>
        <artifactId>objenesis</artifactId>
        <version>${deps.objenesis.version}</version>
        <scope>test</scope>
      </dependency>

      <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>${deps.lombok.version}</version>
        <scope>provided</scope>
        <optional>true</optional>
      </dependency>

      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${deps.slf4j.version}</version>
      </dependency>

      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>${deps.slf4j.version}</version>
        <scope>test</scope>
      </dependency>

      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jul-to-slf4j</artifactId>
        <version>${deps.slf4j.version}</version>
        <scope>test</scope>
      </dependency>

      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>log4j-over-slf4j</artifactId>
        <version>${deps.slf4j.version}</version>
        <scope>test</scope>
      </dependency>

    </dependencies>
  </dependencyManagement>

  <dependencies>

    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
    </dependency>

    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-core</artifactId>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
    </dependency>

    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jcl-over-slf4j</artifactId>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jul-to-slf4j</artifactId>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>log4j-over-slf4j</artifactId>
    </dependency>

  </dependencies>

  <build>
    <pluginManagement>
      <plugins>

        <!-- Defines the source and target version of Java to use for compilation. -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.1</version>
          <configuration>
            <source>${java.version.source}</source>
            <target>${java.version.target}</target>
          </configuration>
        </plugin>

        <!-- Configure the deploy plug-in for some special behaviors. -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.1</version>
          <configuration>
            <!-- Don't deploy any artifacts until everything builds successfully. -->
            <deployAtEnd>true</deployAtEnd>
          </configuration>
        </plugin>

        <!-- Just fixing the version of this plug-in. -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-enforcer-plugin</artifactId>
          <version>1.4</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>${plugins.test-plugin.version}</version>
          <inherited>true</inherited>
          <executions>
            <execution>
              <id>verify</id>
              <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <!-- Just fixing the version of this plug-in. -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-gpg-plugin</artifactId>
          <version>1.5</version>
        </plugin>

        <!-- Just fixing the version of this plug-in. -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>2.4</version>
        </plugin>

        <!-- Configure JavaDoc creation. -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>2.10.3</version>
          <configuration>
            <!-- Shutup Java 8, nobody cares what you think. -->
            <failOnError>false</failOnError>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.rat</groupId>
          <artifactId>apache-rat-plugin</artifactId>
          <version>0.11</version>
          <configuration>
            <excludeSubProjects>false</excludeSubProjects>
            <excludes>
              <exclude>.git/**</exclude>
              <exclude>.gitignore</exclude>
              <exclude>README.md</exclude>
              <exclude>**/target/**</exclude>
              <exclude>**/META-INF/MANIFEST</exclude>
              <exclude>**/.classpath</exclude>
              <exclude>**/.settings/**/*</exclude>
              <exclude>**/.project</exclude>
              <exclude>**/*.iml</exclude>
              <exclude>.idea/**</exclude>
              <exclude>.repository/**</exclude>
              <exclude>**/*.log</exclude>
              <exclude>NOTICE*</exclude>
            </excludes>
          </configuration>
        </plugin>

        <!-- Defines configuration for the Maven based release process. -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.5</version>
          <configuration>
            <autoVersionSubmodules>true</autoVersionSubmodules>
            <tagNameFormat>@{project.version}</tagNameFormat>
          </configuration>
        </plugin>

        <!-- Defines the file encoding for resources in the source tree. -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>2.6</version>
          <configuration>
            <encoding>UTF-8</encoding>
          </configuration>
        </plugin>

        <!-- Set the Surefire plugin version and setup listeners for it -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${plugins.test-plugin.version}</version>
          <inherited>true</inherited>
        </plugin>

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

        <!-- Just fixing the version of this plug-in. -->
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>1.9</version>
        </plugin>

        <!-- Configures m2e to ignore certain plug-ins in Eclipse. -->
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <versionRange>[1.0.0,)</versionRange>
                    <goals>
                      <goal>enforce</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore />
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>

      </plugins>
    </pluginManagement>

    <plugins>

      <!-- Enforce restrictions on where the build may run. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <executions>
          <execution>
            <id>enforce</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <!-- Tries to ensure that we don't end up with an inconsistent classpath without being
                  explicit about it. -->
                <dependencyConvergence />
                <!-- Ensure that the devs and build server are using the right version of Java. -->
                <requireJavaVersion>
                  <version>${java.version.target}</version>
                </requireJavaVersion>
                <!-- Ensure that devs and build server are using the same version of Maven. -->
                <requireMavenVersion>
                  <version>[3.1.0,4.0)</version>
                </requireMavenVersion>
                <!-- Make sure people are not bringing a lot of extra junk with them as debugging these
                  issues wastes time. -->
                <bannedDependencies>
                  <excludes>
                    <exclude>commons-logging:commons-logging</exclude>
                    <exclude>log4j:log4j</exclude>
                    <exclude>org.slf4j:slf4j-log4j</exclude>
                    <exclude>org.slf4j:slf4j-jdk14</exclude>
                    <exclude>org.slf4j:slf4j-nop</exclude>
                    <exclude>org.slf4j:slf4j-simple</exclude>
                    <exclude>com.sun.jersey</exclude>
                    <exclude>javax.ws.rs:jsr311-api</exclude>
                    <exclude>com.codahale.metrics</exclude>
                  </excludes>
                </bannedDependencies>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>

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

      <!-- Inserts GIT information into the Metadata. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifestEntries>
              <Application-Version>${project.version}</Application-Version>
              <Built-By>${build.user}</Built-By>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.rat</groupId>
        <artifactId>apache-rat-plugin</artifactId>
        <executions>
          <execution>
            <phase>verify</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <executions>
          <!-- Make sure that builds always produce a source JAR. Required for deploying to Maven Central. -->
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <executions>
          <!-- Make sure that builds always attach javadocs. Required for deploying to Maven Central. -->
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <!-- Profile that activates when the build is executing on Jenkins. The JENKINS_URL property
         is set by CI server. -->
    <profile>
      <id>jenkins</id>

      <activation>
        <property>
          <name>env.JENKINS_URL</name>
        </property>
      </activation>

      <properties>
        <!-- Set the build user to the triggering user. Environment variables are provided by
             https://wiki.jenkins-ci.org/display/JENKINS/Build+User+Vars+Plugin -->
        <build.user>${env.BUILD_USER_ID} (${env.BUILD_USER})</build.user>
      </properties>

      <build>
        <pluginManagement>
          <plugins>
            <!-- Generates properties file with GIT commit information -->
            <plugin>
              <groupId>pl.project13.maven</groupId>
              <artifactId>git-commit-id-plugin</artifactId>
              <version>2.1.10</version>
            </plugin>
          </plugins>
        </pluginManagement>

        <plugins>
          <!-- Generates properties file with GIT commit information -->
          <plugin>
            <groupId>pl.project13.maven</groupId>
            <artifactId>git-commit-id-plugin</artifactId>
            <executions>
              <execution>
                <goals>
                  <goal>revision</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <verbose>true</verbose>
              <useNativeGit>false</useNativeGit>
              <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
              <generateGitPropertiesFile>true</generateGitPropertiesFile>
              <generateGitPropertiesFilename>target/git.properties</generateGitPropertiesFilename>
              <failOnNoGitDirectory>true</failOnNoGitDirectory>
              <abbrevLength>7</abbrevLength>
              <skip>false</skip>
              <gitDescribe>
                <skip>false</skip>
                <always>false</always>
                <abbrev>7</abbrev>
                <dirty>-dirty</dirty>
                <forceLongFormat>false</forceLongFormat>
              </gitDescribe>
            </configuration>
          </plugin>

          <!-- Sign the artifact -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <configuration>
              <useAgent>false</useAgent>
            </configuration>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <!-- Inserts GIT information into the Metadata -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
              <archive>
                <manifestEntries>
                  <Application-Version>${project.version}</Application-Version>
                  <Built-By>${build.user}</Built-By>
                  <Git-Branch>${git.branch}</Git-Branch>
                  <Git-Commit>${git.commit.id}</Git-Commit>
                </manifestEntries>
              </archive>
            </configuration>
          </plugin>

        </plugins>
      </build>
    </profile>

  </profiles>
</project>
