<?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.2.0</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>bintray-maven</id>
            <name>Bintray repository for releases going to JCenter / Maven Central</name>
            <url>https://api.bintray.com/maven/${bintray.repo}/${bintray.package}</url>
        </repository>

        <snapshotRepository>
            <id>jfrog-oss-snapshot-local</id>
            <name>JFrog OSS repository for deploying snapshots</name>
            <url>https://oss.jfrog.org/oss-snapshot-local</url>
        </snapshotRepository>
    </distributionManagement>

    <repositories>
        <repository>
            <id>jfrog-libs-snapshot</id>
            <name>JFrog OSS snapshots</name>
            <url>https://oss.jfrog.org/libs-snapshot</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>


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

    <properties>
        <slf4j.version>1.7.12</slf4j.version>
        <java.version>1.7</java.version>

        <bintray.repo>jirutka/maven</bintray.repo>
        <bintray.package>${project.artifactId}</bintray.package>

        <checkstyle.config.location>cz/jirutka/maven/codequality/checkstyle.xml</checkstyle.config.location>
        <duplicate-finder.failOnConflict>true</duplicate-finder.failOnConflict>
        <duplicate-finder.skip>false</duplicate-finder.skip>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>


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

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


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

    <build>
        <plugins>
            <!--
                Check the classpath for duplicate classes and resources.
            -->
            <plugin>
                <groupId>com.ning.maven.plugins</groupId>
                <artifactId>maven-duplicate-finder-plugin</artifactId>
                <configuration>
                    <checkTestClasspath>false</checkTestClasspath>
                    <skip>${duplicate-finder.skip}</skip>
                    <failBuildInCaseOfDifferentContentConflict>${duplicate-finder.failOnConflict}</failBuildInCaseOfDifferentContentConflict>
                    <ignoredResources>
                        <ignoredResource>META-INF/.*</ignoredResource>
                        <ignoredResource>/CHANGELOG.*</ignoredResource>
                        <ignoredResource>^[A-Z0-9_-]*\.TXT</ignoredResource>
                    </ignoredResources>
                </configuration>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!--
                Create a build number based on SCM revision.

                Populates properties 'buildNumber' and 'timestamp'.
            -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>buildnumber-maven-plugin</artifactId>
                <configuration>
                    <timestampFormat>{0,date,yyyy-MM-dd'T'HH:mm:ssZ}</timestampFormat>
                    <revisionOnScmFailure>UNKNOWN</revisionOnScmFailure>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>create</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!--
                Compile Java sources using javac compiler.
            -->
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>

            <!--
                Copy resources to the output directory.
            -->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
            </plugin>

            <!--
                Run checkstyle check.
            -->
            <plugin>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <configuration>
                    <consoleOutput>true</consoleOutput>
                    <sourceDirectory>${project.basedir}</sourceDirectory>
                    <includes>/src/**/*.java,/src/**/*.groovy,/src/**/*.xml,/src/**/*.properties,/pom.xml</includes>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>cz.jirutka.maven</groupId>
                        <artifactId>codequality-resources</artifactId>
                        <version>1.2.0</version>
                    </dependency>
                    <dependency>
                        <groupId>com.puppycrawl.tools</groupId>
                        <artifactId>checkstyle</artifactId>
                        <version>6.4.1</version>
                    </dependency>
                </dependencies>
            </plugin>

            <!--
                Run integration tests.
            -->
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <configuration>
                    <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>
                <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>
                <configuration>
                    <additionalparam>-Xdoclint:none</additionalparam>
                    <failOnError>false</failOnError>
                </configuration>
                <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>
                <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>
                <executions>
                    <execution>
                        <id>deploy</id>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>

        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-checkstyle-plugin</artifactId>
                    <version>2.15</version>
                </plugin>

                <plugin>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>2.6.1</version>
                </plugin>

                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.3</version>
                </plugin>

                <plugin>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>2.8.2</version>
                    <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>

                <plugin>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>2.18.1</version>
                </plugin>

                <plugin>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>1.6</version>
                </plugin>

                <plugin>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>2.5.2</version>
                </plugin>

                <plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>2.6</version>
                    <configuration>
                        <archive>
                            <manifest>
                                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            </manifest>
                            <manifestEntries>
                                <Built-Date>${timestamp}</Built-Date>
                                <Implementation-Build>${buildNumber}</Implementation-Build>
                            </manifestEntries>
                        </archive>
                    </configuration>
                </plugin>

                <plugin>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>2.10.3</version>
                </plugin>

                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.7</version>
                </plugin>

                <plugin>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>3.4</version>
                </plugin>

                <plugin>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>2.4</version>
                </plugin>

                <plugin>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.6</version>
                    <configuration>
                        <archive>
                            <manifest>
                                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            </manifest>
                            <manifestEntries>
                                <Built-Date>${timestamp}</Built-Date>
                                <Implementation-Build>${buildNumber}</Implementation-Build>
                            </manifestEntries>
                        </archive>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>com.ning.maven.plugins</groupId>
                    <artifactId>maven-duplicate-finder-plugin</artifactId>
                    <version>1.0.9</version>
                </plugin>

                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>1.9.1</version>
                </plugin>

                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>buildnumber-maven-plugin</artifactId>
                    <version>1.3</version>
                </plugin>

                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.7.5.201505241946</version>
                </plugin>

                <plugin>
                    <groupId>org.eluder.coveralls</groupId>
                    <artifactId>coveralls-maven-plugin</artifactId>
                    <version>4.0.0</version>
                </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>
                <!-- Properties specific for Sonar -->
                <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>
                        <executions>
                            <execution>
                                <id>prepare-agent</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>prepare-agent-integration</id>
                                <goals>
                                    <goal>prepare-agent-integration</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>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <executions>
                            <!-- Merge execution data for unit and integration tests. -->
                            <execution>
                                <id>merge-exec-data</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>merge</goal>
                                </goals>
                                <configuration>
                                    <fileSets>
                                        <fileSet>
                                            <directory>${project.build.directory}</directory>
                                            <includes>
                                                <include>*.exec</include>
                                            </includes>
                                        </fileSet>
                                    </fileSets>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

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

                        To get it work on Travis, add these lines into your .travis.yml:
                            script: 'mvn verify -B'
                            after_success: 'mvn jacoco:report coveralls:jacoco'
                    -->
                    <plugin>
                        <groupId>org.eluder.coveralls</groupId>
                        <artifactId>coveralls-maven-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
