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

    <prerequisites>
        <maven>3.0</maven>
    </prerequisites>


    <!--//////////////////// ABOUT ////////////////////-->

    <groupId>cz.jirutka.maven</groupId>
    <artifactId>root-parent</artifactId>
    <version>1.1.3</version>
    <packaging>pom</packaging>

    <name>Root Parent</name>
    <description>Parent POM for OSS projects.</description>
    <url>http://github.com/jirutka/maven-support</url>
    <inceptionYear>2013</inceptionYear>

    <developers>
        <developer>
            <name>Jakub Jirutka</name>
            <email>jakub@jirutka.cz</email>
            <organization>CTU in Prague</organization>
            <organizationUrl>http://www.cvut.cz</organizationUrl>
        </developer>
    </developers>

    <licenses>
        <license>
            <name>MIT</name>
            <url>http://opensource.org/licenses/MIT</url>
        </license>
    </licenses>


    <!--//////////////////// DISTRIBUTION ////////////////////-->

    <scm>
        <url>http://github.com/jirutka/maven-support</url>
        <connection>scm:git:git@github.com:jirutka/maven-support.git</connection>
    </scm>

    <distributionManagement>
        <repository>
            <id>sonatype-staging</id>
            <name>Sonatype repository for staging releases for Maven Central</name>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
        </repository>

        <snapshotRepository>
            <id>sonatype-snapshots</id>
            <name>Sonatype repository for deploying snapshots</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <repositories>
        <repository>
            <id>sonatype-nexus-snapshots</id>
            <name>Sonatype Nexus Snapshots</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>


    <!--//////////////////// PROPERTIES ////////////////////-->

    <properties>
        <slf4j.version>1.7.6</slf4j.version>
        <java.source.version>1.7</java.source.version>
        <java.target.version>${java.source.version}</java.target.version>
        <checkstyle.config>cz/jirutka/maven/codequality/checkstyle.xml</checkstyle.config>
        <checkstyle.skip>false</checkstyle.skip>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>


    <!--//////////////////// DEPENDENCIES ////////////////////-->

    <dependencies>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
    </dependencies>


    <!--//////////////////// BUILD ////////////////////-->

    <build>
        <plugins>
            <!--
                Compile Java sources using javac compiler.
            -->
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>${java.source.version}</source>
                    <target>${java.target.version}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>

            <!--
                Copy resources to the output directory.
            -->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>

            <!--
                Run checkstyle check.
            -->
            <plugin>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>2.11</version>
                <configuration>
                    <configLocation>${checkstyle.config}</configLocation>
                    <consoleOutput>true</consoleOutput>
                    <skip>${checkstyle.skip}</skip>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>cz.jirutka.maven</groupId>
                        <artifactId>codequality-resources</artifactId>
                        <version>1.1.3</version>
                    </dependency>
                </dependencies>
            </plugin>

            <!--
                Run integration tests.
            -->
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.16</version>
                <configuration>
                    <encoding>${project.build.sourceEncoding}</encoding>
                    <argLine>-Dfile.encoding=${project.build.sourceEncoding}</argLine>
                    <includes>
                        <include>**/*IT.*</include>
                    </includes>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!--
                Create JAR archive with the project sources.
                Will be executed during deploy phase, not install.
            -->
            <plugin>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.2.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!--
                Create JAR archive with the project JavaDoc.
                Will be executed during deploy phase, not install.
            -->
            <plugin>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.9.1</version>
                <executions>
                    <execution>
                        <id>attach-javadoc</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!--
                Sign the project artifacts with GnuPG.

                Will be executed during deploy phase, not install.
                Maven Central requires all artifacts to be signed.
            -->
            <plugin>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>1.5</version>
                <executions>
                    <execution>
                        <id>sign-artifacts</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!--
                Deploy artifacts to remote Maven repository.

                This is explicitly defined here to enforce execution order *after* source, javadoc
                and gpg plugins, thus sources and javadoc are always packaged, signed and deployed
                to Maven repository when performing deploy.
            -->
            <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.1</version>
                <executions>
                    <execution>
                        <id>deploy</id>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>

        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <executions>
                        <!-- Disable execution of deploy plugin defined in super-pom to enforce our execution order. -->
                        <execution>
                            <id>default-deploy</id>
                            <phase>none</phase>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>


    <!--//////////////////// PROFILES ////////////////////-->

    <profiles>
        <!--
            General profile for CI to analyze code coverage.
        -->
        <profile>
            <id>ci</id>

            <!-- Will be automatically activated on Travis CI and possibly other CI environments. -->
            <activation>
                <property>
                    <name>env.CI</name>
                </property>
            </activation>

            <!-- Properties specific for Sonar -->
            <properties>
                <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
                <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
                <sonar.jacoco.itReportPath>${project.build.directory}/jacoco-it.exec</sonar.jacoco.itReportPath>
            </properties>

            <build>
                <plugins>
                    <!--
                        Analyze code coverage with JaCoCo.
                    -->
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>0.6.5.201403032054</version>
                        <executions>
                            <execution>
                                <id>pre-unit-test</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>pre-integration-test</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                                <configuration>
                                    <destFile>${sonar.jacoco.itReportPath}</destFile>
                                    <propertyName>build.failsafe.argLine</propertyName>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!--
                        Redefine failsafe-plugin to run with JaCoCo.
                    -->
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>2.16</version>
                        <configuration>
                            <encoding>${project.build.sourceEncoding}</encoding>
                            <argLine>-Dfile.encoding=${project.build.sourceEncoding} ${build.failsafe.argLine}</argLine>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!--
            Profile for Travis CI to use Coveralls.
        -->
        <profile>
            <id>travis-ci</id>

            <!-- Will be automatically activated on Travis CI. -->
            <activation>
                <property>
                    <name>env.TRAVIS</name>
                </property>
            </activation>

            <build>
                <plugins>
                    <!--
                        Plugin for submitting code coverage reports to Coveralls.

                        To get it work on Travis, add this line into your .travis.yml:
                            after_success: 'mvn jacoco:report coveralls:jacoco -P travis-ci'
                    -->
                    <plugin>
                        <groupId>org.eluder.coveralls</groupId>
                        <artifactId>coveralls-maven-plugin</artifactId>
                        <version>2.2.0</version>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
