<!--

    Copyright 2020 Systems Research Group, University of St Andrews:
    <https://github.com/stacs-srg>

    This file is part of the module common-pom.

    common-pom is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
    License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
    version.

    common-pom is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along with common-pom. If not, see
    <http://www.gnu.org/licenses/>.

-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         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.github.stacs-srg</groupId>
    <artifactId>common-pom</artifactId>
    <version>1.0.2</version>
    <packaging>pom</packaging>
    <name>common-pom</name>

    <description>Common POM for stacs-srg projects</description>
    <url>https://github.com/stacs-srg/common-pom/</url>
    <inceptionYear>2015</inceptionYear>

    <scm>
        <connection>scm:git:git://github.com/stacs-srg/common-pom.git</connection>
        <developerConnection>scm:git:ssh://github.com:stacs-srg/common-pom.git</developerConnection>
        <url>https://github.com/stacs-srg/common-pom/tree/dev</url>
    </scm>

    <organization>
        <name>School of Computer Science at University of St Andrews</name>
        <url>https://www.st-andrews.ac.uk/computer-science/</url>
    </organization>

    <licenses>
        <license>
            <name>GNU General Public License 3.0</name>
            <url>https://www.gnu.org/licenses/gpl-3.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <properties>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <jdk.version>1.8</jdk.version>

        <license.template>src/main/resources/license-template.txt</license.template>
        <license.style>src/main/resources/license-custom-style.xml</license.style>

        <maven.compiler.source>${jdk.version}</maven.compiler.source>
        <maven.compiler.target>${jdk.version}</maven.compiler.target>
        <maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>
        <maven.compiler.showWarnings>true</maven.compiler.showWarnings>

    </properties>

    <dependencies>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13</version>
        </dependency>

    </dependencies>

    <distributionManagement>
        <!-- Central Repository -->
        <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>
    </distributionManagement>

    <build>
        <plugins>

            <plugin>
                <!-- This checks that the required licence, specified in the licence template        -->
                <!-- file src/main/resources/license-template.txt, is applied to all source files.   -->

                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <header>${license.template}</header>

                    <headerDefinitions>

                        <!-- This custom style is used to override the default formatting for Java   -->
                        <!-- files, which uses Javadoc format, therefore causing confusion with the  -->
                        <!-- actual class-level Javadoc.                                             -->
                        <headerDefinition>${license.style}</headerDefinition>

                    </headerDefinitions>

                    <mapping>
                        <java>JAVA_STYLE</java>
                    </mapping>

                    <includes>
                        <include>src/**</include>
                        <include>pom.xml</include>
                    </includes>

                    <excludes>
                        <exclude>**/README</exclude>
                        <exclude>src/test/resources/**</exclude>
                        <exclude>src/main/resources/**</exclude>
                        <exclude>src/docs/**</exclude>
                        <exclude>src/site/**</exclude>
                    </excludes>

                </configuration>

                <executions>
                    <execution>
                        <phase>initialize</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Needed for Codecov -->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.7.9</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>1.6.8</version>
                <extensions>true</extensions>
                <configuration>
                    <serverId>ossrh</serverId>
                    <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                    <autoReleaseAfterClose>true</autoReleaseAfterClose>
                </configuration>
            </plugin>

        </plugins>

    </build>

    <profiles>

        <!-- Deployment profile (required so these plugins are only used when deploying) -->
        <profile>
            <id>deploy</id>
            <build>
                <plugins>
                    <!-- Source plugin -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>3.0.1</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Javadoc plugin -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.0.1</version>
                        <configuration>
                            <show>public</show>
                            <isOffline>false</isOffline>
                        </configuration>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- GPG plugin -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <!-- Prevent `gpg` from using pinentry programs -->
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Custom profile (only enable this plugin when profile manually selected) -->
        <!-- This is because the versions plugin contains an old version of Google
             collections that conflicts with Google guava. -->
        <profile>
            <id>manual</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>versions-maven-plugin</artifactId>
                        <version>2.7</version>
                        <configuration>
                            <excludes>
                                <exclude>org.apache.commons:commons-collections4</exclude>
                            </excludes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

    </profiles>

    <developers>
        <developer>
            <id/>
            <name>Alan Dearle</name>
            <email>alan.dearle@st-andrews.ac.uk</email>
            <url>https://al.host.cs.st-andrews.ac.uk/</url>
            <organization>University of St Andrews</organization>
            <organizationUrl>http://www.st-andrews.ac.uk/</organizationUrl>
            <roles>
                <role>Developer</role>
            </roles>
        </developer>
        <developer>
            <id/>
            <name>Graham Kirby</name>
            <email>graham.kirby@st-andrews.ac.uk</email>
            <url>https://graham.host.cs.st-andrews.ac.uk/</url>
            <organization>University of St Andrews</organization>
            <organizationUrl>http://www.st-andrews.ac.uk/</organizationUrl>
            <roles>
                <role>Developer</role>
            </roles>
        </developer>
        <developer>
            <id/>
            <name>Özgür Akgün</name>
            <email>ozgur.akgun@st-andrews.ac.uk</email>
            <url>https://ozgur.host.cs.st-andrews.ac.uk/</url>
            <organization>University of St Andrews</organization>
            <organizationUrl>http://www.st-andrews.ac.uk/</organizationUrl>
            <roles>
                <role>Developer</role>
            </roles>
        </developer>
        <developer>
            <id/>
            <name>Tom Dalton</name>
            <email>tsd4@st-andrews.ac.uk</email>
            <organization>University of St Andrews</organization>
            <organizationUrl>http://www.st-andrews.ac.uk/</organizationUrl>
            <roles>
                <role>Developer</role>
            </roles>
        </developer>
    </developers>
    <contributors>
        <contributor>
            <name>Masih Hajiarab Derkani</name>
            <organization>Previously University of St Andrews</organization>
            <roles>
                <role>Developer</role>
            </roles>
        </contributor>
    </contributors>

</project>
