<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>

  <parent>
    <groupId>dev.orne</groupId>
    <artifactId>root-pom</artifactId>
    <version>0.1.1</version>
  </parent>

  <artifactId>java-root-pom</artifactId>
  <packaging>pom</packaging>

  <name>Orne Java Root POM</name>
  <description>Orne Java Root POM</description>

  <properties>
    <java.version>1.8</java.version>
    <java.source.version>${java.version}</java.source.version>
    <java.target.version>${java.version}</java.target.version>

    <slf4j.version>1.7.30</slf4j.version>
    <logback.version>1.2.3</logback.version>

    <junit.jupiter.version>5.6.2</junit.jupiter.version>
    <mockito.version>3.3.3</mockito.version>

    <plugins.compiler.version>3.8.1</plugins.compiler.version>
    <plugins.surefire.version>3.0.0-M4</plugins.surefire.version>
    <plugins.failsafe.version>3.0.0-M4</plugins.failsafe.version>
    <plugins.surefire-report.version>3.0.0-M4</plugins.surefire-report.version>
    <plugins.jacoco.version>0.8.5</plugins.jacoco.version>
    <plugins.jar.version>3.2.0</plugins.jar.version>
    <plugins.source.version>3.2.1</plugins.source.version>
    <plugins.javadoc.version>3.2.0</plugins.javadoc.version>
    <plugins.clirr.version>2.8</plugins.clirr.version>
    <plugins.jxr.version>3.0.0</plugins.jxr.version>

    <ut.skip>false</ut.skip>
    <ut.reportDir>${project.build.directory}/ut-reports</ut.reportDir>
    <ut.coverage.reportDir>${project.build.directory}/ut-coverage-reports</ut.coverage.reportDir>
    <it.skip>false</it.skip>
    <it.reportDir>${project.build.directory}/it-reports</it.reportDir>
    <it.coverage.reportDir>${project.build.directory}/it-coverage-reports</it.coverage.reportDir>
    <clirr.reportPath>${project.build.directory}/clirr-report.txt</clirr.reportPath>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${slf4j.version}</version>
      </dependency>
      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>${slf4j.version}</version>
      </dependency>
      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jul-to-slf4j</artifactId>
        <version>${slf4j.version}</version>
      </dependency>
      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>log4j-over-slf4j</artifactId>
        <version>${slf4j.version}</version>
      </dependency>
      <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>${logback.version}</version>
      </dependency>

      <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter</artifactId>
        <version>${junit.jupiter.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-core</artifactId>
        <version>${mockito.version}</version>
        <scope>test</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>license-maven-plugin</artifactId>
          <executions>
            <execution>
              <id>update-license-file</id>
              <goals>
                <goal>update-project-license</goal>
              </goals>
            </execution>
            <execution>
              <id>update-third-party-file</id>
              <goals>
                <goal>add-third-party</goal>
              </goals>
              <configuration>
                <excludedScopes>test,provided</excludedScopes>
              </configuration>
            </execution>
            <execution>
              <id>update-source-license-headers</id>
              <phase>process-sources</phase>
              <goals>
                <goal>update-file-header</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>${plugins.compiler.version}</version>
          <configuration>
            <source>${java.source.version}</source>
            <target>${java.target.version}</target>
            <encoding>${project.build.sourceEncoding}</encoding>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${plugins.surefire.version}</version>
          <configuration>
            <skip>true</skip>
            <reportsDirectory>${ut.reportDir}</reportsDirectory>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>${plugins.failsafe.version}</version>
          <configuration>
            <skip>true</skip>
            <reportsDirectory>${it.reportDir}</reportsDirectory>
            <summaryFile>${it.reportDir}/failsafe-summary.xml</summaryFile>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>${plugins.jacoco.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>${plugins.jar.version}</version>
          <configuration>
            <archive>
              <addMavenDescriptor>false</addMavenDescriptor>
              <manifest>
                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
              </manifest>
              <manifestEntries>
                <Specification-Title>${project.name}</Specification-Title>
                <Specification-Version>${project.version}</Specification-Version>
                <Specification-Vendor>${project.organization.name}</Specification-Vendor>
                <Implementation-Title>${project.name}</Implementation-Title>
                <Implementation-Version>${project.version}</Implementation-Version>
                <Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
                <url>${project.url}</url>
              </manifestEntries>
            </archive>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>${plugins.source.version}</version>
          <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>
          <version>${plugins.javadoc.version}</version>
          <executions>
            <execution>
              <id>attach-javadoc</id>
              <goals>
                <goal>jar</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <failOnError>false</failOnError>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>clirr-maven-plugin</artifactId>
          <version>${plugins.clirr.version}</version>
          <configuration>
            <textOutputFile>${clirr.reportPath}</textOutputFile>
            <linkXRef>true</linkXRef>
            <failOnError>false</failOnError>
          </configuration>
          <executions>
            <execution>
              <id>check-api-compatibility</id>
              <goals>
                <goal>check-no-fork</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jxr-plugin</artifactId>
          <version>${plugins.jxr.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-report-plugin</artifactId>
          <version>${plugins.surefire-report.version}</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>license-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>clirr-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jxr-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>clirr-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </reporting>

  <profiles>
    <profile>
      <id>ut</id>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-surefire-plugin</artifactId>
              <configuration>
                <skip>${ut.skip}</skip>
                <argLine>${ut.coverage.agent.arg}</argLine>
              </configuration>
            </plugin>
            <plugin>
              <groupId>org.jacoco</groupId>
              <artifactId>jacoco-maven-plugin</artifactId>
              <executions>
                <execution>
                  <id>prepare-ut-agent</id>
                  <phase>process-test-classes</phase>
                  <goals>
                    <goal>prepare-agent</goal>
                  </goals>
                  <configuration>
                    <skip>${ut.skip}</skip>
                    <propertyName>ut.coverage.agent.arg</propertyName>
                    <append>true</append>
                  </configuration>
                </execution>
                <execution>
                  <id>generate-ut-coverage-report</id>
                  <phase>verify</phase>
                  <goals>
                    <goal>report</goal>
                  </goals>
                  <configuration>
                    <skip>${ut.skip}</skip>
                    <outputDirectory>${ut.coverage.reportDir}</outputDirectory>
                  </configuration>
                </execution>
              </executions>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
      <reporting>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <reportSets>
              <reportSet>
                <id>unit-tests</id>
                <configuration>
                  <skipSurefireReport>${ut.skip}</skipSurefireReport>
                  <reportsDirectories>
                    <reportsDirectory>${ut.reportDir}</reportsDirectory>
                  </reportsDirectories>
                </configuration>
                <reports>
                  <report>report-only</report>
                </reports>
              </reportSet>
            </reportSets>
          </plugin>
          <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <reportSets>
              <reportSet>
                <id>unit-tests-coverage-report</id>
                <configuration>
                  <skip>${ut.skip}</skip>
                </configuration>
                <reports>
                  <report>report</report>
                </reports>
              </reportSet>
            </reportSets>
          </plugin>
        </plugins>
      </reporting>
    </profile>
    <profile>
      <id>it</id>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-failsafe-plugin</artifactId>
              <executions>
                <execution>
                  <id>integration-test</id>
                  <phase>integration-test</phase>
                  <goals>
                    <goal>integration-test</goal>
                  </goals>
                </execution>
                <execution>
                  <id>verify</id>
                  <phase>verify</phase>
                  <goals>
                    <goal>verify</goal>
                  </goals>
                </execution>
              </executions>
              <configuration>
                <skip>${it.skip}</skip>
                <reportsDirectory>${it.reportDir}</reportsDirectory>
                <summaryFile>${it.reportDir}/failsafe-summary.xml</summaryFile>
                <argLine>${it.coverage.agent.arg}</argLine>
              </configuration>
            </plugin>
            <plugin>
              <groupId>org.jacoco</groupId>
              <artifactId>jacoco-maven-plugin</artifactId>
              <executions>
                <execution>
                  <id>prepare-it-agent</id>
                  <phase>pre-integration-test</phase>
                  <goals>
                    <goal>prepare-agent-integration</goal>
                  </goals>
                  <configuration>
                    <skip>${it.skip}</skip>
                    <propertyName>it.coverage.agent.arg</propertyName>
                    <append>true</append>
                  </configuration>
                </execution>
                <execution>
                  <id>generate-it-coverage-report</id>
                  <phase>verify</phase>
                  <goals>
                    <goal>report-integration</goal>
                  </goals>
                  <configuration>
                    <skip>${it.skip}</skip>
                    <outputDirectory>${it.coverage.reportDir}</outputDirectory>
                  </configuration>
                </execution>
              </executions>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
      <reporting>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <reportSets>
              <reportSet>
                <id>integration-tests-report</id>
                <configuration>
                  <skipFailsafeReport>${it.skip}</skipFailsafeReport>
                  <reportsDirectories>
                    <reportsDirectory>${it.reportDir}</reportsDirectory>
                  </reportsDirectories>
                </configuration>
                <reports>
                  <report>failsafe-report-only</report>
                </reports>
              </reportSet>
            </reportSets>
          </plugin>
          <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <reportSets>
                <reportSet>
                  <id>integration-tests-coverage-report</id>
                  <configuration>
                    <skip>${it.skip}</skip>
                  </configuration>
                  <reports>
                    <report>report-integration</report>
                  </reports>
              </reportSet>
            </reportSets>
          </plugin>
        </plugins>
      </reporting>
    </profile>
    <profile>
      <id>pre-release</id>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>clirr-maven-plugin</artifactId>
              <configuration>
                <failOnError>false</failOnError>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
    <profile>
      <id>release</id>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>clirr-maven-plugin</artifactId>
              <configuration>
                <failOnError>true</failOnError>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
    <profile>
      <id>major-release</id>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>clirr-maven-plugin</artifactId>
              <configuration>
                <failOnError>false</failOnError>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
  </profiles>

</project>
