<?xml version="1.0" encoding="UTF-8"?>
<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>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.1.RELEASE</version>
        <relativePath/>
    </parent>

    <groupId>com.github.choonchernlim</groupId>
    <artifactId>spring-boot-ci</artifactId>
    <version>0.4.0</version>
    <packaging>pom</packaging>

    <name>Spring Boot CI</name>
    <description>Spring-Boot-friendly parent POM to 1) generate static code analysis reports for CI server,
        2) deploy artifacts to Sonatype OSSRH, and 3) deploy site documentation to GitHub.
    </description>
    <url>https://github.com/choonchernlim/spring-boot-ci</url>

    <licenses>
        <license>
            <name>MIT License</name>
            <url>http://www.opensource.org/licenses/mit-license.php</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <id>choonchernlim</id>
            <name>Choon-Chern Lim</name>
            <email>choonchernlim@gmail.com</email>
            <url>https://github.com/choonchernlim</url>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git@github.com:choonchernlim/spring-boot-ci.git</connection>
        <developerConnection>scm:git:git@github.com:choonchernlim/spring-boot-ci.git</developerConnection>
        <url>git@github.com:choonchernlim/spring-boot-ci.git</url>
    </scm>

    <properties>
        <java.version>1.8</java.version>

        <groovy-eclipse-compiler.version>3.0.0-01</groovy-eclipse-compiler.version>
        <groovy-eclipse-batch.version>2.5.4-01</groovy-eclipse-batch.version>

        <maven.version>3.3.9</maven.version>

        <!--
        To get Spock to work with @SpringBootTest.
        See https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html#boot-features-testing-spring-boot-applications-with-spock
        -->
        <spock.version>1.2-groovy-2.5</spock.version>

        <!-- Dependency versions (only those that are not defined in `spring-boot-starter-parent`) -->
        <cglib-nodep.version>3.2.9</cglib-nodep.version>

        <!-- Plugin versions (only those that are not defined in `spring-boot-starter-parent`) -->
        <jacoco-maven-plugin.version>0.8.2</jacoco-maven-plugin.version>
        <maven-project-info-reports-plugin.version>3.0.0</maven-project-info-reports-plugin.version>
        <maven-jxr-plugin.version>3.0.0</maven-jxr-plugin.version>
        <jdepend-maven-plugin.version>2.0</jdepend-maven-plugin.version>
        <maven-pmd-plugin.version>3.11.0</maven-pmd-plugin.version>
        <findbugs-maven-plugin.version>3.0.5</findbugs-maven-plugin.version>
        <taglist-maven-plugin.version>2.4</taglist-maven-plugin.version>
        <nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
        <site-maven-plugin.version>0.12</site-maven-plugin.version>
        <maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
        <keytool-maven-plugin.version>1.5</keytool-maven-plugin.version>

        <!-- Spring Boot doesn't have this property... so, this is needed -->
        <maven-surefire-report-plugin.version>3.0.0-M1</maven-surefire-report-plugin.version>

        <!-- Overriding Spring Boot's version so that this version matches Maven Surefire Report Plugin version -->
        <maven-surefire-plugin.version>3.0.0-M1</maven-surefire-plugin.version>
        <surefire-junit47.version>3.0.0-M1</surefire-junit47.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>cglib</groupId>
                <artifactId>cglib-nodep</artifactId>
                <version>${cglib-nodep.version}</version>
            </dependency>
            <dependency>
                <groupId>org.spockframework</groupId>
                <artifactId>spock-spring</artifactId>
                <version>${spock.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${jacoco-maven-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-project-info-reports-plugin</artifactId>
                    <version>${maven-project-info-reports-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jxr-plugin</artifactId>
                    <version>${maven-jxr-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>jdepend-maven-plugin</artifactId>
                    <version>${jdepend-maven-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-pmd-plugin</artifactId>
                    <version>${maven-pmd-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>findbugs-maven-plugin</artifactId>
                    <version>${findbugs-maven-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>taglist-maven-plugin</artifactId>
                    <version>${taglist-maven-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.sonatype.plugins</groupId>
                    <artifactId>nexus-staging-maven-plugin</artifactId>
                    <version>${nexus-staging-maven-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>com.github.github</groupId>
                    <artifactId>site-maven-plugin</artifactId>
                    <version>${site-maven-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>${maven-gpg-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>keytool-maven-plugin</artifactId>
                    <version>${keytool-maven-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-report-plugin</artifactId>
                    <version>${maven-surefire-report-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-eclipse-compiler</artifactId>
                    <version>${groovy-eclipse-compiler.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>${maven-javadoc-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>${maven-source-plugin.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <!--
            Use Groovy compiler.
            https://github.com/groovy/groovy-eclipse/wiki/Groovy-Eclipse-Maven-plugin
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <compilerId>groovy-eclipse-compiler</compilerId>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy-eclipse-compiler</artifactId>
                        <version>${groovy-eclipse-compiler.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy-eclipse-batch</artifactId>
                        <version>${groovy-eclipse-batch.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

            <!--
            Handle possible missing `src/main/java` and `src/test/java` when using Groovy.
            https://github.com/groovy/groovy-eclipse/wiki/Groovy-Eclipse-Maven-plugin
            -->
            <plugin>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy-eclipse-compiler</artifactId>
                <extensions>true</extensions>
            </plugin>

            <!--
            Enable Spring Boot support.
            http://docs.spring.io/spring-boot/docs/current/maven-plugin/
            -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <!--
                    Create 2 artifacts: one as dependency and another as executable fat JAR
                    See https://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html#howto-create-an-additional-executable-jar
                    -->
                    <classifier>exec</classifier>
                </configuration>
            </plugin>

            <!--
            Versions Maven Plugin - Makes it easier to upgrade plugins and dependencies
            http://www.mojohaus.org/versions-maven-plugin/
            -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
            </plugin>

            <!--
            Surefire Maven Plugin - Runs unit tests.
            http://maven.apache.org/surefire/maven-surefire-plugin/
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <!-- Redirect JBoss logging to SLF4J -->
                    <systemPropertyVariables>
                        <org.jboss.logging.provider>slf4j</org.jboss.logging.provider>
                    </systemPropertyVariables>

                    <!-- The first 4 patterns are SureFire's default. Adding Spock's `*Spec` default pattern. -->
                    <includes>
                        <include>**/Test*.class</include>
                        <include>**/*Test.class</include>
                        <include>**/*Tests.class</include>
                        <include>**/*TestCase.class</include>
                        <include>**/*Spec.class</include>
                    </includes>
                    <excludes>
                        <exclude>**/Abstract*.class</exclude>
                    </excludes>
                </configuration>
                <!--
                Specify JUnit as provider manually so that it will not accidentally detect
                other test frameworks such as TestNG.
                -->
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.surefire</groupId>
                        <artifactId>surefire-junit47</artifactId>
                        <version>${surefire-junit47.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

            <!--
            Maven Failsafe Plugin - Runs integration tests.
            http://maven.apache.org/surefire/maven-failsafe-plugin/
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!--
            Maven Site Plugin - Generates site.
            http://maven.apache.org/plugins/maven-site-plugin/
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <configuration>
                    <relativizeDecorationLinks>false</relativizeDecorationLinks>
                </configuration>
                <executions>
                    <!--
                    In Maven 3, site:attach-descriptor has been removed from the built-in lifecycle bindings,
                    so need to explicitly define `attach-descriptor` goal to pick up src/site/site.xml.
                    -->
                    <execution>
                        <id>attach-descriptor</id>
                        <goals>
                            <goal>attach-descriptor</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!--
            JaCoCo Maven Plugin - Code coverage report for JVM languages.
            http://www.eclemma.org/jacoco/
            -->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>**/generated/**</exclude>
                        <exclude>**/scratch/**</exclude>
                    </excludes>
                </configuration>
                <executions>
                    <execution>
                        <id>default-prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-prepare-agent-integration</id>
                        <goals>
                            <goal>prepare-agent-integration</goal>
                        </goals>
                    </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>

            <!--
            Maven Enforcer Plugin - Bans certain dependencies and ensure minimum Maven version is used.
            http://maven.apache.org/enforcer/maven-enforcer-plugin/
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                    <!--
                    If these banned dependencies exist, fail the build right away.

                    Xalan, Xerces and Xml-APIs - Known to cause problem when deployed to server. Use the ones
                    provided by server.
                    See http://stackoverflow.com/questions/11677572/dealing-with-xerces-hell-in-java-maven
                    -->
                    <execution>
                        <id>enforce-banned-dependencies</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <fail>true</fail>
                            <rules>
                                <bannedDependencies>
                                    <excludes>
                                        <exclude>xalan</exclude>
                                        <exclude>xerces</exclude>
                                        <exclude>xml-apis</exclude>
                                    </excludes>
                                </bannedDependencies>
                            </rules>
                        </configuration>
                    </execution>
                    <!--
                    Ensures everyone is using at least the specified Maven version or later.
                    -->
                    <execution>
                        <id>enforce-maven</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireMavenVersion>
                                    <version>${maven.version}</version>
                                </requireMavenVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!--
            Maven Source Plugin - Generates source JAR file.
            https://maven.apache.org/plugins/maven-source-plugin/
            -->
            <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>
        </plugins>
    </build>

    <reporting>
        <plugins>
            <!--
            Maven Project Info Reports Plugin - Generates reports information about the project.
            https://maven.apache.org/plugins/maven-project-info-reports-plugin/
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <configuration>
                    <dependencyDetailsEnabled>false</dependencyDetailsEnabled>
                </configuration>
            </plugin>

            <!--
            Maven Surefire Reports Plugin - Parses generated test results from both unit tests and integration tests.
            http://maven.apache.org/surefire/maven-surefire-report-plugin/
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>failsafe-report-only</report>
                            <report>report-only</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>

            <!--
            JaCoCo Maven Plugin - Code coverage report for JVM languages.
            http://www.eclemma.org/jacoco/
            -->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>report</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>

            <!--
            Maven Javadoc Plugin - Generates Javadoc.
            https://maven.apache.org/plugins/maven-javadoc-plugin/
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <!--
                    Shuts off non-error and non-warning messages, leaving only the warnings and errors
                    appear, making them easier to view.
                    -->
                    <quiet>true</quiet>
                </configuration>
            </plugin>

            <!--
            Maven JXR Plugin - Generates a cross-reference of the project's sources.
            http://maven.apache.org/plugins/maven-jxr-plugin/
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
            </plugin>

            <!--
            JDepend Maven Plugin - Generates design quality metrics for each Java package.
            http://www.mojohaus.org/jdepend-maven-plugin/
            -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jdepend-maven-plugin</artifactId>
            </plugin>

            <!--
            Maven PMD Plugin - Generates PMD and CPD reports.
            http://maven.apache.org/plugins/maven-pmd-plugin/
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <configuration>
                    <!--suppress MavenModelInspection -->
                    <targetJdk>${jdk.version}</targetJdk>
                    <excludes>
                        <exclude>**/generated/**</exclude>
                        <exclude>**/scratch/**</exclude>
                    </excludes>
                    <excludeRoots>
                        <excludeRoot>target/generated-sources</excludeRoot>
                    </excludeRoots>
                </configuration>
            </plugin>

            <!--
            FindBugs Maven Plugin - Inspects Java bytecode for occurrences of bug patterns.
            http://www.mojohaus.org/findbugs-maven-plugin/
            -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <configuration>
                    <xmlOutput>true</xmlOutput>
                </configuration>
            </plugin>

            <!--
            TagList Maven Plugin - Generates a report on various tags found in the code.
            http://www.mojohaus.org/taglist-maven-plugin/
            -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>taglist-maven-plugin</artifactId>
                <configuration>
                    <tagListOptions>
                        <tagClasses>
                            <tagClass>
                                <displayName>Todo</displayName>
                                <tags>
                                    <tag>
                                        <matchString>todo</matchString>
                                        <matchType>ignoreCase</matchType>
                                    </tag>
                                    <tag>
                                        <matchString>FIXME</matchString>
                                        <matchType>exact</matchType>
                                    </tag>
                                </tags>
                            </tagClass>
                            <tagClass>
                                <displayName>Cleanup</displayName>
                                <tags>
                                    <tag>
                                        <matchString>@deprecated</matchString>
                                        <matchType>exact</matchType>
                                    </tag>
                                </tags>
                            </tagClass>
                        </tagClasses>
                    </tagListOptions>
                </configuration>
            </plugin>
        </plugins>
    </reporting>

    <repositories>
        <!--
        To fix "Failure to find com.gemstone.gemfire:gemfire:pom:x.x.x" error thrown by
        `maven-project-info-reports-plugin`
        -->
        <repository>
            <id>spring-plugins-repository</id>
            <name>Spring Plugins Repository</name>
            <url>http://repo.spring.io/plugins-release/</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <!-- To pick up latest Groovy-related artifacts -->
        <pluginRepository>
            <id>bintray</id>
            <name>Groovy Bintray</name>
            <url>https://dl.bintray.com/groovy/maven</url>
            <releases>
                <updatePolicy>never</updatePolicy>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

    <profiles>
        <!--
        `ossrh` profile pushes binary, source code and javadoc to Sonatype OSSRH and generated site to GitHub.
        -->
        <profile>
            <id>ossrh</id>
            <build>
                <plugins>
                    <!--
                    Nexus Staging Maven Plugin - Deploys to Sonatype OSSRH.
                    https://github.com/sonatype/nexus-maven-plugins/tree/master/staging/maven-plugin
                    -->
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>

                    <!--
                    Maven Source Plugin - Generates source code.
                    https://maven.apache.org/plugins/maven-source-plugin/
                    -->
                    <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>

                    <!--
                    GitHub Site Plugin - Generates Maven site in project GitHub page.
                    https://github.com/github/maven-plugins
                    -->
                    <plugin>
                        <groupId>com.github.github</groupId>
                        <artifactId>site-maven-plugin</artifactId>
                        <configuration>
                            <message>Creating site for ${project.version}</message>
                            <server>github</server>
                            <!--
                            Need to disable Jekyll because JaCoCo static files are stored in `.resources` directory.
                            -->
                            <noJekyll>true</noJekyll>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>site</goal>
                                </goals>
                                <phase>site</phase>
                            </execution>
                        </executions>
                    </plugin>

                    <!--
                    Maven Javadoc Plugin - Generates Javadoc.
                    https://maven.apache.org/plugins/maven-javadoc-plugin/
                    -->
                    <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>
                        <configuration>
                            <!--
                            Shuts off non-error and non-warning messages, leaving only the warnings and errors
                            appear, making them easier to view.
                            -->
                            <quiet>true</quiet>
                        </configuration>
                    </plugin>

                    <!--
                    Maven GPG Plugin - Signs all of the project's attached artifacts with GnuPG.
                    http://maven.apache.org/plugins/maven-gpg-plugin/
                    -->
                    <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>
                                <configuration>
                                    <!--
                                    GPG 2.1 requires this setting to pick up `gpg.passphrase` defined in `settings.xml`.
                                    -->
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>

            <distributionManagement>
                <snapshotRepository>
                    <id>ossrh</id>
                    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
                </snapshotRepository>
            </distributionManagement>
        </profile>
    </profiles>
</project>