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

  <artifactId>freelib-parent</artifactId>
  <name>FreeLibrary Parent Project</name>
  <description>A Parent POM for FreeLibrary Projects</description>
  <packaging>pom</packaging>

  <properties>
    <!-- FreeLibrary projects whose versions are managed through this parent -->
    <freelib.resources.version>${project.parent.version}</freelib.resources.version>

    <!-- Dependencies managed through this parent project -->
    <junit.version>4.12</junit.version>
    <xom.version>1.2.5</xom.version>
    <slf4j.version>1.7.12</slf4j.version>
    <xmlunit.version>1.6</xmlunit.version>
    <groovy.version>2.3.6</groovy.version>
    <logback.version>1.1.3</logback.version>
    <pegdown.version>1.5.0</pegdown.version>
    <phantomjs.version>1.9.7</phantomjs.version>
    <ghostdriver.version>1.1.0</ghostdriver.version>

    <!-- Maven plugin dependencies managed through this parent project -->
    <maven.core.version>3.2.5</maven.core.version>
    <maven.plugin.api.version>3.2.5</maven.plugin.api.version>
    <maven.plugin.annotations.version>3.4</maven.plugin.annotations.version>

    <!-- Plugins managed through/in pluginManagement section -->
    <sonar.plugin.version>2.6</sonar.plugin.version>
    <jetty.version>9.2.10.v20150310</jetty.version>
    <maven.verifier.version>1.4</maven.verifier.version>
    <maven.filtering.version>1.3</maven.filtering.version>
    <phantomjs.plugin.version>0.4</phantomjs.plugin.version>
    <exec.maven.plugin.version>1.3.2</exec.maven.plugin.version>
    <maven.plugin.plugin.version>3.4</maven.plugin.plugin.version>
    <maven.clean.plugin.version>2.6.1</maven.clean.plugin.version>
    <maven.install.plugin.version>2.3.1</maven.install.plugin.version>
    <enforce.victims.rule.version>1.3.4</enforce.victims.rule.version>
    <maven.failsafe.plugin.version>2.17</maven.failsafe.plugin.version>
    <maven.enforcer.plugin.version>1.4.1</maven.enforcer.plugin.version>
    <maven.javadoc.plugin.version>2.10.2</maven.javadoc.plugin.version>
    <maven.surefire.plugin.version>2.18.1</maven.surefire.plugin.version>
    <maven.resources.plugin.version>2.7</maven.resources.plugin.version>
    <maven.dependency.plugin.version>2.10</maven.dependency.plugin.version>
    <build.helper.maven.plugin.version>1.6</build.helper.maven.plugin.version>
    <properties.maven.plugin.version>1.0-alpha-2</properties.maven.plugin.version>

    <!-- Configure the project's character encodings -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

    <!-- Disable the default site generation; we'll use jbake instead -->
    <maven.site.skip>true</maven.site.skip>
    <jbake.outputDirectory>target/site</jbake.outputDirectory>
    <jbake.maven.plugin.version>0.0.9</jbake.maven.plugin.version>

    <!-- We want to override the skip tests directive in our parent project -->
    <maven.test.skip>false</maven.test.skip>

    <!-- Location used for finding the unpacked checkstyle-suppressions.xml file -->
    <!-- It's a built-in configuration for eclipse-cs tool; make it work with Maven -->
    <config_loc>${project.basedir}/target/site/checkstyle</config_loc>
    <maven.checkstyle.version>2.17</maven.checkstyle.version>
    <checkstyle.version>6.16</checkstyle.version>

    <!-- The extension we use to push site productions up to an S3 bucket -->
    <maven.s3.wagon.version>1.2.1</maven.s3.wagon.version>

    <!-- Jacoco and Sonar configuration -->
    <jacoco.outputDir>${project.build.directory}</jacoco.outputDir>
    <jacoco.out.unit.file>jacoco-ut.exec</jacoco.out.unit.file>
    <jacoco.out.it.file>jacoco-it.exec</jacoco.out.it.file>
    <sonar.jacoco.reportPath>${jacoco.outputDir}/${jacoco.out.unit.file}</sonar.jacoco.reportPath>
    <sonar.jacoco.itReportPath>${jacoco.outputDir}/${jacoco.out.it.file}</sonar.jacoco.itReportPath>
    <jacoco.maven.plugin.version>0.7.4.201502262128</jacoco.maven.plugin.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${slf4j.version}</version>
      </dependency>
      <dependency>
        <groupId>xom</groupId>
        <artifactId>xom</artifactId>
        <version>${xom.version}</version>
      </dependency>
      <!-- Below dependencies are only used for testing -->
      <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>${logback.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>xmlunit</groupId>
        <artifactId>xmlunit</artifactId>
        <version>${xmlunit.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>com.github.detro.ghostdriver</groupId>
        <artifactId>phantomjsdriver</artifactId>
        <version>${ghostdriver.version}</version>
        <scope>test</scope>
      </dependency>
      <!-- Dependencies for Maven plugins -->
      <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-plugin-api</artifactId>
        <version>${maven.plugin.api.version}</version>
      </dependency>
      <dependency>
        <groupId>org.apache.maven.plugin-tools</groupId>
        <artifactId>maven-plugin-annotations</artifactId>
        <version>${maven.plugin.annotations.version}</version>
        <scope>provided</scope>
      </dependency>
      <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-core</artifactId>
        <version>${maven.core.version}</version>
      </dependency>
      <dependency>
        <groupId>org.apache.maven.shared</groupId>
        <artifactId>maven-verifier</artifactId>
        <version>${maven.verifier.version}</version>
        <scope>test</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-install-plugin</artifactId>
          <version>${maven.install.plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-plugin-plugin</artifactId>
          <version>${maven.plugin.plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>properties-maven-plugin</artifactId>
          <version>${properties.maven.plugin.version}</version>
        </plugin>
        <!-- Installs PhantomJS so it doesn't have to be pre-installed -->
        <plugin>
          <groupId>com.github.klieber</groupId>
          <artifactId>phantomjs-maven-plugin</artifactId>
          <version>${phantomjs.plugin.version}</version>
          <executions>
            <execution>
              <goals>
                <goal>install</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <version>${phantomjs.version}</version>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>${build.helper.maven.plugin.version}</version>
          <configuration>
            <portNames>
              <portName>http.port</portName>
              <portName>http.port.stop</portName>
            </portNames>
          </configuration>
          <executions>
            <execution>
              <id>reserve-port</id>
              <phase>initialize</phase>
              <goals>
                <goal>reserve-network-port</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>${maven.dependency.plugin.version}</version>
          <executions>
            <execution>
              <id>unpack-build-resources</id>
              <phase>generate-resources</phase>
              <goals>
                <goal>unpack</goal>
              </goals>
              <configuration>
                <artifactItems>
                  <artifactItem>
                    <groupId>info.freelibrary</groupId>
                    <artifactId>freelib-resources</artifactId>
                    <version>${freelib.resources.version}</version>
                    <type>jar</type>
                    <includes>eclipse/**/*,checkstyle/**/*</includes>
                    <outputDirectory>${basedir}/target/build-resources</outputDirectory>
                  </artifactItem>
                </artifactItems>
              </configuration>
            </execution>
            <execution>
              <id>unpack-site-resources</id>
              <phase>pre-site</phase>
              <goals>
                <goal>unpack</goal>
              </goals>
              <configuration>
                <artifactItems>
                  <artifactItem>
                    <groupId>info.freelibrary</groupId>
                    <artifactId>freelib-resources</artifactId>
                    <version>${freelib.resources.version}</version>
                    <type>jar</type>
                    <includes>jbake/**/*</includes>
                    <outputDirectory>${basedir}/target</outputDirectory>
                  </artifactItem>
                </artifactItems>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>${maven.resources.plugin.version}</version>
          <dependencies>
            <dependency>
              <groupId>org.apache.maven.shared</groupId>
              <artifactId>maven-filtering</artifactId>
              <version>${maven.filtering.version}</version>
            </dependency>
          </dependencies>
          <executions>
            <execution>
              <id>copy-build-resources</id>
              <phase>process-resources</phase>
              <goals>
                <goal>copy-resources</goal>
              </goals>
              <configuration>
                <outputDirectory>${basedir}/target/site</outputDirectory>
                <resources>
                  <resource>
                    <directory>${basedir}/target/build-resources</directory>
                    <filtering>true</filtering>
                  </resource>
                </resources>
              </configuration>
            </execution>
            <execution>
              <id>copy-site-resources</id>
              <phase>pre-site</phase>
              <goals>
                <goal>copy-resources</goal>
              </goals>
              <configuration>
                <outputDirectory>${basedir}/target/jbake</outputDirectory>
                <resources>
                  <resource>
                    <directory>${basedir}/src/main/jbake</directory>
                    <filtering>true</filtering>
                  </resource>
                </resources>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-enforcer-plugin</artifactId>
          <version>${maven.enforcer.plugin.version}</version>
          <dependencies>
            <dependency>
              <groupId>com.redhat.victims</groupId>
              <artifactId>enforce-victims-rule</artifactId>
              <version>${enforce.victims.rule.version}</version>
              <type>jar</type>
            </dependency>
          </dependencies>
          <executions>
            <execution>
              <id>enforce-victims-rule</id>
              <goals>
                <goal>enforce</goal>
              </goals>
              <configuration>
                <rules>
                  <rule implementation="com.redhat.victims.VictimsRule">
                    <metadata>fatal</metadata>
                    <fingerprint>fatal</fingerprint>
                    <updates>daily</updates>
                  </rule>
                </rules>
              </configuration>
            </execution>
            <execution>
              <id>enforce-no-snapshots</id>
              <goals>
                <goal>enforce</goal>
              </goals>
              <configuration>
                <failFast>true</failFast>
                <rules>
                  <requireReleaseDeps>
                    <onlyWhenRelease>false</onlyWhenRelease>
                    <failWhenParentIsSnapshot>false</failWhenParentIsSnapshot>
                    <message>
                      <![CDATA[Sorry, dependency snapshots are not allowed! To temporarily ignore this]]>
                      <![CDATA[restriction add the following to the command line: -Denforcer.skip=true]]>
          </message>
                  </requireReleaseDeps>
                </rules>
                <fail>true</fail>
              </configuration>
            </execution>
            <execution>
              <id>enforce-java</id>
              <goals>
                <goal>enforce</goal>
              </goals>
              <configuration>
                <rules>
                  <requireJavaVersion>
                    <version>[1.8.0,)</version>
                  </requireJavaVersion>
                </rules>
              </configuration>
            </execution>
            <execution>
              <id>enforce-maven</id>
              <goals>
                <goal>enforce</goal>
              </goals>
              <configuration>
                <rules>
                  <requireMavenVersion>
                    <version>[3.2.2,)</version>
                  </requireMavenVersion>
                </rules>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <version>${maven.checkstyle.version}</version>
          <configuration>
            <consoleOutput>true</consoleOutput>
            <logViolationsToConsole>false</logViolationsToConsole>
            <violationSeverity>warning</violationSeverity>
            <configLocation>${basedir}/target/site/checkstyle/checkstyle.xml</configLocation>
          </configuration>
          <dependencies>
            <dependency>
              <groupId>com.puppycrawl.tools</groupId>
              <artifactId>checkstyle</artifactId>
              <version>${checkstyle.version}</version>
            </dependency>
          </dependencies>
          <executions>
            <execution>
              <id>checkstyle</id>
              <phase>verify</phase>
              <goals>
                <goal>check</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>${maven.javadoc.plugin.version}</version>
          <dependencies>
            <dependency>
              <groupId>info.freelibrary</groupId>
              <artifactId>freelib-resources</artifactId>
              <version>${freelib.resources.version}</version>
            </dependency>
          </dependencies>
          <configuration>
            <stylesheetfile>javadocs.css</stylesheetfile>
            <nonavbar>true</nonavbar>
            <nosince>true</nosince>
            <notimestamp>true</notimestamp>
            <bottom> </bottom>
            <detectLinks>true</detectLinks>
            <links>
              <link>http://www.xmlunit.org/api/java/master</link>
            </links>
          </configuration>
          <executions>
            <execution>
              <id>site-javadocs</id>
              <phase>site</phase>
              <goals>
                <goal>javadoc</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>br.com.ingenieux</groupId>
          <artifactId>jbake-maven-plugin</artifactId>
          <version>${jbake.maven.plugin.version}</version>
          <dependencies>
            <dependency>
              <groupId>org.pegdown</groupId>
              <artifactId>pegdown</artifactId>
              <version>${pegdown.version}</version>
            </dependency>
            <dependency>
              <groupId>org.codehaus.groovy</groupId>
              <artifactId>groovy</artifactId>
              <version>${groovy.version}</version>
            </dependency>
            <dependency>
              <groupId>org.codehaus.groovy</groupId>
              <artifactId>groovy-templates</artifactId>
              <version>${groovy.version}</version>
            </dependency>
          </dependencies>
          <configuration>
            <inputDirectory>${basedir}/target/jbake</inputDirectory>
          </configuration>
          <executions>
            <execution>
              <id>site-docs</id>
              <phase>site</phase>
              <goals>
                <goal>generate</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>sonar-maven-plugin</artifactId>
          <version>${sonar.plugin.version}</version>
          <executions>
            <execution>
              <id>sonar-metrics</id>
              <phase>post-site</phase>
              <goals>
                <goal>sonar</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${maven.surefire.plugin.version}</version>
          <configuration>
            <!-- Our integration tests shouldn't be run as unit tests -->
            <excludes>
              <exclude>**/*IT.java</exclude>
              <exclude>**/*IntegrationTest.java</exclude>
              <exclude>**/*FunctionalTest.java</exclude>
            </excludes>
            <forkCount>3</forkCount>
            <reuseForks>true</reuseForks>
            <argLine>-XX:MaxMetaspaceSize=512m ${jacoco.agent.unit.arg}</argLine>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>exec-maven-plugin</artifactId>
          <version>${exec.maven.plugin.version}</version>
          <executions>
            <execution>
              <goals>
                <goal>java</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <systemProperties>
              <systemProperty>
                <key>logback.configurationFile</key>
                <value>src/main/resources/logback.xml</value>
              </systemProperty>
            </systemProperties>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>${maven.failsafe.plugin.version}</version>
          <configuration>
            <argLine>-XX:MaxMetaspaceSize=128m ${jacoco.agent.it.arg}</argLine>
            <includes>
              <include>**/*IT.java</include>
              <include>**/*IntegrationTest.java</include>
            </includes>
          </configuration>
          <executions>
            <execution>
              <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>${jacoco.maven.plugin.version}</version>
          <executions>
            <execution>
              <id>default-prepare-agent</id>
              <goals>
                <goal>prepare-agent</goal>
              </goals>

              <configuration>
                <destFile>${sonar.jacoco.reportPath}</destFile>
                <propertyName>jacoco.agent.unit.arg</propertyName>
                <append>true</append>
              </configuration>
            </execution>
            <execution>
              <id>default-prepare-agent-integration</id>
              <goals>
                <goal>prepare-agent-integration</goal>
              </goals>
              <configuration>
                <destFile>${sonar.jacoco.itReportPath}</destFile>
                <propertyName>jacoco.agent.it.arg</propertyName>
                <append>true</append>
              </configuration>
            </execution>
            <execution>
              <id>default-report</id>
              <goals>
                <goal>report</goal>
              </goals>
            </execution>
            <execution>
              <id>default-report-integration</id>
              <goals>
                <goal>report-integration</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>${maven.enforcer.plugin.version}</version>
      </plugin>
    </plugins>
    <extensions>
      <extension>
        <groupId>org.kuali.maven.wagons</groupId>
        <artifactId>maven-s3-wagon</artifactId>
        <version>${maven.s3.wagon.version}</version>
      </extension>
    </extensions>
  </build>

  <!-- Profiles that should be inherited by child projects -->
  <profiles>
    <!-- The release-sign-artifacts profile allows for the publishing of project artifact -->
    <profile>
      <id>release-sign-artifacts</id>
      <activation>
        <property>
          <name>performRelease</name>
          <value>true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <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>

  <parent>
    <groupId>info.freelibrary</groupId>
    <artifactId>freelib-build-tools</artifactId>
    <version>0.1.2</version>
  </parent>
</project>
