<?xml version="1.0"?>
<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.fossgalaxy.common</groupId>
  <artifactId>parent-pom</artifactId>
  <version>0.4</version>
  <packaging>pom</packaging>

  <name>FOSS Galaxy POM</name>
  <description>A super POM for FOSS Galaxy projects.</description>
  <url>http://${fossgalaxy.owner.id}.fosslab.uk/${fossgalaxy.repo.id}/</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <!-- Require java 1.8 -->
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>

    <!-- plugin versions -->
    <plugins.javadoc.version>3.0.0</plugins.javadoc.version>
    <plugins.source.version>3.0.1</plugins.source.version>
    <plugins.site.version>3.7</plugins.site.version>
    <plugins.jacoco.version>0.8.1</plugins.jacoco.version>
    <plugins.release.version>2.5.3</plugins.release.version>

    <!-- fossgalaxy specific -->
    <fossgalaxy.owner.id>infrastructure</fossgalaxy.owner.id>
    <fossgalaxy.repo.id>${project.artifactId}</fossgalaxy.repo.id>
  </properties>

  <!-- by default, we assume GPLv3 -->
  <licenses>
    <license>
      <name>GNU General Public License, Version 3.0</name>
      <url>https://www.gnu.org/licenses/gpl-3.0.txt</url>
    </license>
  </licenses>

  <!-- FOSS Galaxy Git SCM settings -->
  <scm>
    <connection>scm:git:git://git@git.fossgalaxy.com/${fossgalaxy.owner.id}/${fossgalaxy.repo.id}.git</connection>
    <developerConnection>scm:git:ssh://git@git.fossgalaxy.com/${fossgalaxy.owner.id}/${fossgalaxy.repo.id}.git</developerConnection>
    <url>https://git.fossgalaxy.com/${fossgalaxy.owner.id}/${fossgalaxy.repo.id}</url>
    <tag>v0.4</tag>
  </scm>

  <!-- tag FossGalaxy projects -->
  <organization>
    <name>FOSS Galaxy</name>
    <url>https://www.fossgalaxy.com</url>
  </organization>

  <!-- people you should contact about the code -->
  <developers>
    <developer>
      <id>webpigeon</id>
      <name>Joseph Walton-Rivers</name>
      <email>webpigeon@fossgalaxy.com</email>
    </developer>
  </developers>

  <!-- We use sonatype ossrh for maven deployments -->
  <distributionManagement>
    <snapshotRepository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
    <site>
      <id>fossgalaxy.website.static</id>
      <url>scp://docs.fossgalaxy.com/srv/public_sites/${project.artifactId}</url>
    </site>
  </distributionManagement>

  <!-- reports for the website -->
  <reporting>
    <plugins>

      <!-- Maven javadocs -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>${plugins.javadoc.version}</version>
      </plugin>

    </plugins>
  </reporting>

  <profiles>

    <!-- when doing releases build javadocs, source and sign them -->
    <profile>
      <id>release</id>
      <build>
        <plugins>

          <!-- generate source code jars -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>${plugins.source.version}</version>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar-no-fork</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <!-- generate javadoc jar -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>${plugins.javadoc.version}</version>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <!-- GPG sign all of the jars -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>1.5</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>

    </profile>
  </profiles>

  <build>
    <plugins>

      <!-- Require maven >= 3.0 -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>3.0.0-M1</version>
        <executions>
          <execution>
            <id>enforce-maven</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireMavenVersion>
                  <version>3.0</version>
                </requireMavenVersion>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- ensure that the parent site.xml is used for all projects -->
      <plugin>
        <artifactId>maven-site-plugin</artifactId>
        <version>${plugins.site.version}</version>
        <executions>
          <execution>
            <id>attach-descriptor</id>
            <goals>
              <goal>attach-descriptor</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- JUnit test coverage -->
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${plugins.jacoco.version}</version>
        <executions>
          <execution>
            <id>jacoco-initialize</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <execution>
            <id>jacoco-site</id>
            <phase>package</phase>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- use release plugin for well-defined releases -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <version>${plugins.release.version}</version>
        <configuration>
          <tagNameFormat>v@{project.version}</tagNameFormat>
          <releaseProfiles>release</releaseProfiles>
          <goals>deploy</goals>
        </configuration>
      </plugin>

    </plugins>
  </build>

</project>
