<?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">
    <parent>
        <artifactId>pom-project</artifactId>
        <groupId>at.rseiler</groupId>
        <version>1.0</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <packaging>pom</packaging>
    <groupId>at.rseiler.pom-project</groupId>
    <artifactId>pom</artifactId>
    <version>1.0</version>
    <name>${project.groupId}:${project.artifactId}</name>
    <description>
        The POM is indented to be used as a parent POM and to speed up the setup/configuration of a new project.
    </description>

    <properties>
        <!-- config -->
        <skipTests>false</skipTests>
        <skipITs>true</skipITs>
        <skipCodeAnalysis>false</skipCodeAnalysis>

        <!-- multi project config -->
        <main.basedir>${project.parent.basedir}</main.basedir>
        <skipDependencyPlugin>false</skipDependencyPlugin>

        <!-- general config -->
        <java.version>1.8</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- common libs -->
        <version.commons-lang>3.3.2</version.commons-lang>
        <version.commons-codec>1.7</version.commons-codec>

        <!-- logging and monitoring -->
        <version.log4j>1.2.17</version.log4j>

        <!-- testing -->
        <version.mockito>1.9.5</version.mockito>
        <version.junit>4.12</version.junit>

        <!-- static source code analysis tools -->
        <version.findbugs>3.0.0</version.findbugs>
        <version.pmd>3.3</version.pmd>
        <version.checkstyle>2.13</version.checkstyle>

        <!-- maven plugins -->
        <maven.surefire.plugin.version>2.18.1</maven.surefire.plugin.version>
        <maven-failsafe-plugin.version>2.18.1</maven-failsafe-plugin.version>
        <maven.site.plugin.version>3.4</maven.site.plugin.version>
        <maven-jxr-plugin.version>2.5</maven-jxr-plugin.version>
        <maven-compiler-plugin.version>3.2</maven-compiler-plugin.version>
        <jacoco-maven-plugin.version>0.7.2.201409121644</jacoco-maven-plugin.version>
        <taglist-maven-plugin.version>2.4</taglist-maven-plugin.version>
        <maven-javadoc-plugin.version>2.10.1</maven-javadoc-plugin.version>
        <maven-dependency-plugin.version>2.10</maven-dependency-plugin.version>
        <maven-project-info-reports-plugin.version>2.7</maven-project-info-reports-plugin.version>
        <doxia-module-markdown.version>1.6</doxia-module-markdown.version>
        <maven-source-plugin.version>2.4</maven-source-plugin.version>
        <maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
        <maven-gpg-plugin.version>1.5</maven-gpg-plugin.version>
        <maven-release-plugin.version>2.5.1</maven-release-plugin.version>

        <!-- maven plugin config -->
        <cpd-minimumTokens>100</cpd-minimumTokens>
        <checkstyle.version>6.1.1</checkstyle.version>

        <!-- environment dependent properties -->
        <script.extension/>

        <arguments/>
    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- logging -->
            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>${version.log4j}</version>
            </dependency>

            <!-- testing -->
            <dependency>
                <groupId>org.junit</groupId>
                <artifactId>junit</artifactId>
                <version>${version.junit}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-all</artifactId>
                <version>${version.mockito}</version>
                <scope>test</scope>
            </dependency>

            <!-- utilities -->
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>${version.commons-lang}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>at.rseiler.pom-project</groupId>
            <artifactId>annotation</artifactId>
            <version>1.0</version>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <!--unpack config for static code analysis -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>${maven-dependency-plugin.version}</version>
                </plugin>

                <!-- code analysis -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-pmd-plugin</artifactId>
                    <version>${version.pmd}</version>
                    <configuration>
                        <failurePriority>3</failurePriority>
                        <targetJdk>${java.version}</targetJdk>
                        <rulesets>
                            <ruleset>${main.basedir}/target/config/code-analysis/pmd-ruleset.xml</ruleset>
                        </rulesets>
                        <excludes>
                            <exclude>**/generated/**</exclude>
                        </excludes>
                        <excludeRoots>
                            <excludeRoot>target/generated-sources/**</excludeRoot>
                        </excludeRoots>
                        <minimumTokens>${cpd-minimumTokens}</minimumTokens>
                        <skip>${skipCodeAnalysis}</skip>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>findbugs-maven-plugin</artifactId>
                    <version>${version.findbugs}</version>
                    <configuration>
                        <effort>Max</effort>
                        <threshold>Low</threshold>
                        <skip>${skipCodeAnalysis}</skip>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-checkstyle-plugin</artifactId>
                    <version>${version.checkstyle}</version>
                    <dependencies>
                        <dependency>
                            <groupId>com.puppycrawl.tools</groupId>
                            <artifactId>checkstyle</artifactId>
                            <version>${checkstyle.version}</version>
                        </dependency>
                    </dependencies>
                    <configuration>
                        <failOnViolation>false</failOnViolation>
                        <logViolationsToConsole>true</logViolationsToConsole>
                        <configLocation>${main.basedir}/target/config/code-analysis/checkstyle.xml</configLocation>
                        <suppressionsLocation>${main.basedir}/target/config/code-analysis/checkstyle-suppression.xml
                        </suppressionsLocation>
                        <skip>${skipCodeAnalysis}</skip>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>${maven-release-plugin.version}</version>
                    <configuration>
                        <useReleaseProfile>false</useReleaseProfile>
                        <goals>deploy</goals>
                        <arguments>-Prelease ${arguments}</arguments>
                        <waitBeforeTagging>10</waitBeforeTagging>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven-compiler-plugin.version}</version>
                </plugin>
                <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-surefire-plugin</artifactId>
                    <version>${maven.surefire.plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>${maven-failsafe-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>${maven.site.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-javadoc-plugin</artifactId>
                    <version>${maven-javadoc-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>taglist-maven-plugin</artifactId>
                    <version>${taglist-maven-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>${maven-source-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>${maven-deploy-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>${maven-gpg-plugin.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${maven.compiler.target}</source>
                    <target>${maven.compiler.target}</target>
                    <compilerArgument>-parameters</compilerArgument>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>at.rseiler.pom-project</groupId>
                                    <artifactId>config</artifactId>
                                    <version>1.0</version>
                                    <classifier>config</classifier>
                                    <type>zip</type>
                                    <outputDirectory>${main.basedir}/target/config</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <configuration>
                    <includes>
                        <include>at/rseiler/**</include>
                    </includes>
                    <excludes>
                        <exclude>**/generated/**</exclude>
                    </excludes>
                    <skip>${skipTests}</skip>
                </configuration>
                <executions>
                    <execution>
                        <id>setup-surfire1</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <destFile>${project.build.directory}/jacoco1.exec</destFile>
                            <propertyName>surefire1ArgLine</propertyName>
                        </configuration>
                    </execution>
                    <execution>
                        <id>setup-surfire2</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <destFile>${project.build.directory}/jacoco2.exec</destFile>
                            <propertyName>surefire2ArgLine</propertyName>
                        </configuration>
                    </execution>
                    <execution>
                        <id>setup-failsafe</id>
                        <goals>
                            <goal>prepare-agent-integration</goal>
                        </goals>
                        <configuration>
                            <destFile>${project.build.directory}/jacoco-it.exec</destFile>
                            <propertyName>failsafeArgLine</propertyName>
                        </configuration>
                    </execution>
                    <execution>
                        <id>merge-ut-reports</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>
                            <destFile>${project.build.directory}/jacoco.exec</destFile>
                        </configuration>
                    </execution>
                    <execution>
                        <id>generate-overall-report</id>
                        <goals>
                            <goal>merge</goal>
                            <goal>report</goal>
                        </goals>
                        <phase>pre-site</phase>
                        <configuration>
                            <fileSets>
                                <fileSet>
                                    <directory>${project.build.directory}</directory>
                                    <includes>
                                        <include>*.exec</include>
                                    </includes>
                                </fileSet>
                            </fileSets>
                            <destFile>${project.build.directory}/jacoco-merged.exec</destFile>
                            <dataFile>${project.build.directory}/jacoco-merged.exec</dataFile>
                            <outputDirectory>${project.reporting.outputDirectory}/jacoco-merged</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <workingDirectory>${basedir}</workingDirectory>
                    <parallel>classes</parallel>
                    <threadCount>2</threadCount>
                    <perCoreThreadCount>true</perCoreThreadCount>
                    <skipTests>${skipTests}</skipTests>
                </configuration>
                <executions>
                    <execution>
                        <id>default-test</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <excludedGroups>at.rseiler.annotation.junit.ThreadUnsafe</excludedGroups>

                            <!-- Sets the VM argument line used when unit tests are run. -->
                            <argLine>${surefire1ArgLine}</argLine>
                        </configuration>
                    </execution>
                    <execution>
                        <id>thread-unsafe-tests</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <phase>test</phase>
                        <configuration>
                            <reuseForks>true</reuseForks>
                            <forkCount>2C</forkCount>
                            <groups>at.rseiler.annotation.junit.ThreadUnsafe</groups>

                            <!-- Sets the VM argument line used when unit tests are run. -->
                            <argLine>${surefire2ArgLine}</argLine>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <configuration>
                    <parallel>classes</parallel>
                    <threadCount>4</threadCount>
                    <perCoreThreadCount>true</perCoreThreadCount>

                    <includes>
                        <include>**/*ITest.java</include>
                    </includes>

                    <!-- Sets the VM argument line used when unit tests are run. -->
                    <argLine>${failsafeArgLine}</argLine>

                    <skipTests>${skipTests}</skipTests>
                    <skipITs>${skipITs}</skipITs>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <executions>
                    <!-- used for multi project builds -->
                    <execution>
                        <id>attach-descriptor</id>
                        <goals>
                            <goal>attach-descriptor</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <!-- to use the markdown format -->
                    <dependency>
                        <groupId>org.apache.maven.doxia</groupId>
                        <artifactId>doxia-module-markdown</artifactId>
                        <version>${doxia-module-markdown.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <!-- use a newer version of checkstyle which supports java 8 -->
                <dependencies>
                    <dependency>
                        <groupId>com.puppycrawl.tools</groupId>
                        <artifactId>checkstyle</artifactId>
                        <version>${checkstyle.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <configuration>
                    <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
                </configuration>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>index</report>
                            <!--<report>cim</report>-->
                            <report>dependencies</report>
                            <!--<report>dependency-convergence</report>-->
                            <report>dependency-info</report>
                            <report>dependency-management</report>
                            <!--<report>distribution-management</report>-->
                            <!--<report>issue-tracking</report>-->
                            <report>license</report>
                            <!--<report>mailing-list</report>-->
                            <report>modules</report>
                            <report>plugin-management</report>
                            <report>project-team</report>
                            <report>scm</report>
                            <report>summary</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <configuration>
                    <skip>${skipDependencyPlugin}</skip>
                </configuration>
                <reportSets>
                    <reportSet>
                        <id>analyze-report</id>
                        <inherited>false</inherited>
                        <reports>
                            <report>analyze-report</report>
                        </reports>
                        <configuration>
                            <skip>${skipDependencyPlugin}</skip>
                        </configuration>
                    </reportSet>
                </reportSets>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <excludePackageNames>*.generated.*</excludePackageNames>
                </configuration>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>javadoc</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <reportSets>
                    <reportSet>
                        <id>aggregate</id>
                        <inherited>false</inherited>
                        <reports>
                            <report>aggregate</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>taglist-maven-plugin</artifactId>
                <configuration>
                    <tagListOptions>
                        <tagClasses>
                            <tagClass>
                                <displayName>Todo Work</displayName>
                                <tags>
                                    <tag>
                                        <matchString>todo</matchString>
                                        <matchType>ignoreCase</matchType>
                                    </tag>
                                    <tag>
                                        <matchString>fixme</matchString>
                                        <matchType>ignoreCase</matchType>
                                    </tag>
                                </tags>
                            </tagClass>
                            <tagClass>
                                <displayName>@deprecated</displayName>
                                <tags>
                                    <tag>
                                        <matchString>@deprecated</matchString>
                                        <matchType>exact</matchType>
                                    </tag>
                                </tags>
                            </tagClass>
                        </tagClasses>
                    </tagListOptions>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>${maven.surefire.plugin.version}</version>
                <configuration>
                    <!-- set it to false for big projects -->
                    <showSuccess>true</showSuccess>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco-maven-plugin.version}</version>
                <configuration>
                    <includes>
                        <include>at/rseiler/**</include>
                    </includes>
                    <excludes>
                        <exclude>**/generated/**</exclude>
                    </excludes>
                </configuration>
            </plugin>

            <!-- code analysis -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
            </plugin>
        </plugins>
    </reporting>

    <profiles>
        <profile>
            <id>staticCodeAnalysis</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-pmd-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>analyze-pmd</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>analyze-cdp</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>cpd-check</goal>
                                </goals>
                                <configuration>
                                    <failOnViolation>false</failOnViolation>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>findbugs-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>analyze-findbugs</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-checkstyle-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>analyze-checkstyle</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>execITs</id>
            <activation>
                <property>
                    <name>execITs</name>
                </property>
            </activation>
            <properties>
                <skipITs>false</skipITs>
            </properties>
        </profile>

        <profile>
            <id>skipTests</id>
            <activation>
                <property>
                    <name>skipTests</name>
                </property>
            </activation>
            <properties>
                <skipTests>true</skipTests>
            </properties>
        </profile>

        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <inherited>true</inherited>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <inherited>true</inherited>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-deploy-plugin</artifactId>
                        <inherited>true</inherited>
                        <configuration>
                            <updateReleaseInfo>true</updateReleaseInfo>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <developers>
        <developer>
            <id>rseiler</id>
            <name>Reinhard Seiler</name>
            <email>rseiler.developer@gmail.com</email>
            <roles>
                <role>developer</role>
            </roles>
        </developer>
    </developers>

</project>