<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.smartcodeltd</groupId>
    <artifactId>release-candidate-maven-plugin</artifactId>
    <version>1.0-201603091838.01dbbbf</version>
    <packaging>maven-plugin</packaging>

    <name>Release Candidate</name>
    <description>Enabling Continuous Delivery with Maven</description>

    <url>http://smartcodeltd.co.uk/release-candidate-maven-plugin/</url>

    <issueManagement>
        <url>https://github.com/smartcodeltd/release-candidate-maven-plugin/issues</url>
        <system>GitHub Issues</system>
    </issueManagement>

    <prerequisites>
        <maven>${maven.version}</maven>
    </prerequisites>

    <licenses>
        <license>
            <name>New BSD License</name>
            <url>file://${project.basedir}/LICENSE.md</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <scm>
        <url>https://github.com/smartcodeltd/release-candidate-maven-plugin</url>
        <connection>scm:git:ssh://git@github.com/smartcodeltd/release-candidate-maven-plugin.git</connection>
        <developerConnection>scm:git:ssh://git@github.com/smartcodeltd/release-candidate-maven-plugin.git</developerConnection>
    </scm>

    <distributionManagement>
        <repository>
            <id>bintray</id>
            <url>https://api.bintray.com/maven/jan-molak/maven/release-candidate-maven-plugin</url>
        </repository>
    </distributionManagement>

    <organization>
        <name>smartcode ltd</name>
        <url>http://smartcodeltd.co.uk</url>
    </organization>

    <developers>
        <developer>
            <id>jan-molak</id>
            <name>Jan Molak</name>
            <email>jan.molak+release-candidate@smartcodeltd.co.uk</email>
            <url>http://smartcodeltd.co.uk</url>
            <organization>smartcode ltd</organization>
            <organizationUrl>http://smartcodeltd.co.uk</organizationUrl>
            <timezone>Europe/London</timezone>
        </developer>
    </developers>

    <properties>
        <maven.version>3.2.5</maven.version>
        <maven-plugin-plugin.version>3.4</maven-plugin-plugin.version>
        <release-candidate-plugin.version>1.0-SNAPSHOT</release-candidate-plugin.version>
        <jacoco-plugin.version>0.7.4.201502262128</jacoco-plugin.version>

        <maven.compiler.source>1.6</maven.compiler.source>
        <maven.compiler.target>1.6</maven.compiler.target>

        <encoding>UTF-8</encoding>
        <showDeprecation>true</showDeprecation>
        <compilerArgument>-Xlint:all,-serial</compilerArgument>
    </properties>

    <dependencies>
        <dependency>
            <groupId>de.pdark</groupId>
            <artifactId>decentxml</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>18.0</version>
        </dependency>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.8.1</version>
        </dependency>

        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>

        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-plugin-api</artifactId>
            <version>${maven.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.codehaus.plexus</groupId>
                    <artifactId>plexus-utils</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.codehaus.plexus</groupId>
                    <artifactId>plexus-classworlds</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-core</artifactId>
            <version>${maven.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.codehaus.plexus</groupId>
                    <artifactId>plexus-utils</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.guava</groupId>
                    <artifactId>guava</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-model</artifactId>
            <version>${maven.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-compat</artifactId>
            <version>${maven.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.codehaus.plexus</groupId>
                    <artifactId>plexus-utils</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-artifact</artifactId>
            <version>${maven.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugin-tools</groupId>
            <artifactId>maven-plugin-annotations</artifactId>
            <version>${maven-plugin-plugin.version}</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.maven</groupId>
                    <artifactId>maven-artifact</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.codehaus.plexus</groupId>
            <artifactId>plexus-utils</artifactId>
            <version>3.0.20</version>
        </dependency>

        <!-- test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.9.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugin-testing</groupId>
            <artifactId>maven-plugin-testing-harness</artifactId>
            <version>3.3.0</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.codehaus.plexus</groupId>
                    <artifactId>plexus-utils</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-plugin-plugin</artifactId>
                <version>${maven-plugin-plugin.version}</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.8</version>
                <configuration>
                    <anonymousConnection>scm:git:git@github.com:smartcodeltd/release-candidate-maven-plugin.git</anonymousConnection>
                    <developerConnection>scm:git:git@github.com:smartcodeltd/release-candidate-maven-plugin.git</developerConnection>
                </configuration>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>summary</report>
                            <report>license</report>
                            <report>modules</report>
                            <report>project-team</report>
                            <report>scm</report>
                            <report>issue-tracking</report>
                            <report>dependencies</report>
                            <report>dependency-convergence</report>
                            <report>plugins</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
        </plugins>
    </reporting>

    <build>
        <plugins>
            <!-- maven plugin development-specific stuff -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.16</version>
                <configuration>
                    <testFailureIgnore>false</testFailureIgnore>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-plugin-plugin</artifactId>
                <version>${maven-plugin-plugin.version}</version>
                <configuration>
                    <goalPrefix>release-candidate</goalPrefix>
                    <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
                </configuration>
                <executions>
                    <execution>
                        <id>mojo-descriptor</id>
                        <goals>
                            <goal>descriptor</goal>
                        </goals>
                        <phase>process-classes</phase>
                    </execution>
                    <execution>
                        <id>help-goal</id>
                        <goals>
                            <goal>helpmojo</goal>
                        </goals>
                        <phase>process-classes</phase>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>sisu-maven-plugin</artifactId>
                <version>1.4</version>
                <executions>
                    <execution>
                        <id>generate-index</id>
                        <goals>
                            <goal>main-index</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- documentation -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.4</version>
                <dependencies>
                    <dependency>
                        <groupId>lt.velykis.maven.skins</groupId>
                        <artifactId>reflow-velocity-tools</artifactId>
                        <version>1.1.1</version>
                    </dependency>
                    <!-- Reflow skin requires Velocity >= 1.7  -->
                    <dependency>
                        <groupId>org.apache.velocity</groupId>
                        <artifactId>velocity</artifactId>
                        <version>1.7</version>
                    </dependency>
                </dependencies>
            </plugin>

            <plugin>
                <groupId>com.google.code.maven-replacer-plugin</groupId>
                <artifactId>replacer</artifactId>
                <version>1.5.3</version>
                <executions>
                    <execution>
                        <phase>site</phase>
                        <goals>
                            <goal>replace</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <includes>
                        <include>${project.build.directory}/site/*.html</include>
                    </includes>
                    <replacements>
                        <replacement>
                            <token>@GROUP_ID</token>
                            <value>${project.groupId}</value>
                        </replacement>
                        <replacement>
                            <token>@ARTIFACT_ID</token>
                            <value>${project.artifactId}</value>
                        </replacement>
                        <replacement>
                            <token>@VERSION</token>
                            <value>${project.version}</value>
                        </replacement>
                    </replacements>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-invoker-plugin</artifactId>
                <version>2.0.0</version>
                <configuration>
                    <projectsDirectory>src/it</projectsDirectory>
                    <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
                    <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
                    <settingsFile>src/it/settings.xml</settingsFile>
                    <showErrors>true</showErrors>
                    <streamLogs>true</streamLogs>
                    <pomIncludes>
                        <pomInclude>*/pom.xml</pomInclude>
                    </pomIncludes>
                    <postBuildHookScript>verify</postBuildHookScript>
                    <mavenOpts>-Xmx256m</mavenOpts>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <goals>
                            <goal>install</goal>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <streamLogs>false</streamLogs>
                            <debug>true</debug>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>version</id>
            <build>
                <plugins>
                    <!-- release candidate configuration -->
                    <plugin>
                        <groupId>com.smartcodeltd</groupId>
                        <artifactId>release-candidate-maven-plugin</artifactId>
                        <version>${release-candidate-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>default-cli</id>
                                <goals>
                                    <goal>updateVersion</goal>
                                </goals>
                                <configuration>
                                    <releaseVersionFormat>{{ api_version }}-{{ timestamp('YYYYMMddHHmm') }}.${revision}</releaseVersionFormat>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- make sure that ${revision} is specified as it's needed to set the new version -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-enforcer-plugin</artifactId>
                        <version>1.4</version>
                        <executions>
                            <execution>
                                <id>default-cli</id>
                                <goals>
                                    <goal>enforce</goal>
                                </goals>
                                <configuration>
                                    <rules>
                                        <requireProperty>
                                            <property>revision</property>
                                            <message>Please specify the `revision` property</message>
                                            <regex>[a-f0-9]{7}</regex>
                                            <regexMessage>revision should be a 7 character long identifier, generated by
                                                running `git rev-parse --short HEAD`
                                            </regexMessage>
                                        </requireProperty>
                                    </rules>
                                    <fail>true</fail>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>rc</id>
            <build>
                <plugins>
                    <!-- release candidate configuration -->
                    <plugin>
                        <groupId>com.smartcodeltd</groupId>
                        <artifactId>release-candidate-maven-plugin</artifactId>
                        <version>${release-candidate-plugin.version}</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>version</goal>
                                </goals>
                                <configuration>
                                    <outputTemplate>PROJECT_VERSION={{ version }}</outputTemplate>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- record test coverage -->
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>${jacoco-plugin.version}</version>
                        <configuration>
                            <destFile>${project.build.directory}/coverage/jacoco-unit.exec</destFile>
                            <dataFile>${project.build.directory}/coverage/jacoco-unit.exec</dataFile>
                        </configuration>
                        <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>

                    <!-- attach sources -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>2.4</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

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

                    <!-- publish a tag to github -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-scm-plugin</artifactId>
                        <version>1.9.4</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>tag</goal>
                                </goals>
                                <phase>deploy</phase>
                            </execution>
                        </executions>
                        <configuration>
                            <basedir>${project.basedir}</basedir>
                            <tag>${project.version}</tag>
                            <message>Release candidate ${project.version}</message>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>publish</id>
            <build>
                <plugins>
                    <!-- github pages -->
                    <plugin>
                        <groupId>com.github.github</groupId>
                        <artifactId>site-maven-plugin</artifactId>
                        <version>0.12</version>
                        <configuration>
                            <server>github</server>
                            <message>Creating the site for ${project.version}</message>
                            <userName>smartcode-ci</userName>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>site</goal>
                                </goals>
                                <phase>site</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>