<?xml version="1.0" encoding="UTF-8"?>
<!--
  #%L
  wcm.io
  %%
  Copyright (C) 2014 wcm.io
  %%
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  #L%
  -->

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>io.wcm.maven</groupId>
    <artifactId>io.wcm.maven.global-parent</artifactId>
    <version>42</version>
    <relativePath/>
  </parent>

  <groupId>io.wcm.maven</groupId>
  <artifactId>io.wcm.maven.parent</artifactId>
  <version>2.0.0</version>
  <packaging>pom</packaging>

  <name>Maven Tooling</name>
  <description>Maven Parent POMs, Build Tools and Plugins.</description>
  <url>${site.url}/${site.url.module.prefix}/</url>

  <scm>
    <connection>scm:git:https://github.com/wcm-io/io.wcm.maven.parent.git</connection>
    <developerConnection>scm:git:https://github.com/wcm-io/io.wcm.maven.parent.git</developerConnection>
    <url>https://github.com/wcm-io/io.wcm.maven.parent</url>
    <tag>HEAD</tag>
  </scm>

  <inceptionYear>2014</inceptionYear>

  <organization>
    <name>wcm.io</name>
    <url>https://wcm.io</url>
  </organization>

  <issueManagement>
    <system>JIRA</system>
    <url>https://wcm-io.atlassian.net/browse/</url>
  </issueManagement>

  <developers>
    <developer>
      <name>wcm.io Community</name>
      <organization>wcm.io</organization>
      <organizationUrl>https://wcm.io</organizationUrl>
    </developer>
  </developers>

  <licenses>
    <license>
      <name>The Apache Software License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>

  <properties>
    <!-- Java version -->
    <java.version>1.8</java.version>
    <build.compiler.release>8</build.compiler.release>

    <!-- site settings -->
    <site.url.module.prefix>tooling/maven</site.url.module.prefix>
    <site.url>https://wcm.io</site.url>
    <site.deploy.id>ssh-wcm.io</site.deploy.id>
    <site.deploy.url>scm:git:https://github.com/wcm-io/wcm-io.github.io.git</site.deploy.url>

    <!-- set default empty argLine when not executing jacoco -->
    <argLine />

    <!-- Set to 'enabled' to activate org.eclipse.jdt.core.compiler.annotation.nullanalysis feature in eclipse settings -->
    <eclipse.settings.nullanalysis>enabled</eclipse.settings.nullanalysis>

    <!-- SonarCloud -->
    <sonar.organization>wcm-io</sonar.organization>
    <sonar.host.url>https://sonarcloud.io</sonar.host.url>

  </properties>
  
  <!-- default dependencies for all projects -->
  <dependencies>

    <!-- Recommended global dependency for nullability annotations -->
    <dependency>
      <groupId>org.jetbrains</groupId>
      <artifactId>annotations</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- Spotbugs annotations -->
    <dependency>
      <groupId>io.wcm.tooling.spotbugs</groupId>
      <artifactId>io.wcm.tooling.spotbugs.annotations</artifactId>
      <scope>provided</scope>
    </dependency>

  </dependencies>

  <dependencyManagement>
    <dependencies>

      <!-- Testing -->
      <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit-bom</artifactId>
        <version>5.8.2</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-core</artifactId>
        <version>4.2.0</version>
      </dependency>
      <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-junit-jupiter</artifactId>
        <version>4.2.0</version>
      </dependency>

      <!-- Maven Plugin Tooling -->
      <dependency>
        <groupId>org.apache.maven.plugin-tools</groupId>
        <artifactId>maven-plugin-annotations</artifactId>
        <version>3.6.4</version>
      </dependency>

    </dependencies>
  </dependencyManagement>

  <build>
    <extensions>

      <!-- Add wcm.io file header to code templates -->
      <extension>
        <groupId>io.wcm.maven</groupId>
        <artifactId>io.wcm.maven.global-build-tools-mixin</artifactId>
        <version>2</version>
      </extension>

    </extensions>
    <plugins>

      <!-- license check -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>license-maven-plugin</artifactId>
        <executions>
          <execution>
            <phase>validate</phase>
            <goals>
              <goal>check-file-header</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- site configuration -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <dependencies>
          <dependency>
            <groupId>io.wcm.maven.skins</groupId>
            <artifactId>reflow-velocity-tools</artifactId>
            <version>1.0.2</version>
          </dependency>
          <!-- Reflow skin requires Velocity >= 1.7  -->
          <dependency>
            <groupId>org.apache.velocity</groupId>
            <artifactId>velocity</artifactId>
            <version>1.7</version>
          </dependency>
        </dependencies>
        <configuration>
          <generateReports>true</generateReports>
          <inputEncoding>UTF-8</inputEncoding>
          <outputEncoding>UTF-8</outputEncoding>
          <topSiteURL>${site.deploy.url}</topSiteURL>
        </configuration>
        <executions>
          <execution>
            <id>attach-descriptor</id>
            <goals>
              <goal>attach-descriptor</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-scm-publish-plugin</artifactId>
        <inherited>false</inherited>
        <configuration>
          <subDirectory>${site.url.module.prefix}</subDirectory>
          <skipDeletedFiles>true</skipDeletedFiles>
        </configuration>
      </plugin>

    </plugins>
    <pluginManagement>
      <plugins>

        <!-- Maven Plugin Tooling -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-plugin-plugin</artifactId>
          <version>3.6.4</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-invoker-plugin</artifactId>
          <version>3.2.2</version>
        </plugin>

        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>license-maven-plugin</artifactId>
          <configuration>
            <licenseName>apache_v2</licenseName>
            <addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
            <projectName>wcm.io</projectName>
            <excludes>
              <exclude>**/*.json</exclude>
              <exclude>**/*.html</exclude>
            </excludes>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <configuration>
            <notimestamp>true</notimestamp>
            <!-- Avoid https://bugs.openjdk.java.net/browse/JDK-8212233 while building for Java 8 -->
            <detectJavaApiLink>false</detectJavaApiLink> 
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <configuration>

            <!-- Activate parallel test execution for JUnit 5 (run classes concurrently, methods sequentially) -->
            <properties>
              <configurationParameters>
                junit.jupiter.execution.parallel.enabled = true
                junit.jupiter.execution.parallel.mode.default = same_thread
                junit.jupiter.execution.parallel.mode.classes.default = concurrent
              </configurationParameters>
            </properties>

          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-release-plugin</artifactId>
          <configuration>
            <projectVersionPolicyId>OddEvenVersionPolicy</projectVersionPolicyId>
          </configuration>
          <dependencies>
            <dependency>
              <groupId>org.apache.maven.release</groupId>
              <artifactId>maven-release-oddeven-policy</artifactId>
              <version>${maven-release-plugin.version}</version>
            </dependency>
           </dependencies>
        </plugin>

      </plugins>

    </pluginManagement>
  </build>

  <reporting>
    <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-project-info-reports-plugin</artifactId>
        <inherited>true</inherited>
        <reportSets>
          <reportSet>
            <reports>
              <report>index</report>
              <report>dependencies</report>
              <report>scm</report>
              <report>licenses</report>
              <report>summary</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-changes-plugin</artifactId>
        <configuration>
          <!-- Allow HTML markup in CDATA sections in changes reports -->
          <escapeHTML>false</escapeHTML>
          <!-- Do not generate links to teamlist reports -->
          <teamlist>none</teamlist>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <reportSets>
          <reportSet>
            <reports>
              <!-- select non-aggregate reports -->
              <report>report</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>

    </plugins>
  </reporting>

  <profiles>

    <!-- Skip integration tests in "fast" profile -->
    <profile>
      <id>fast</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <properties>
        <!-- Skip maven-invoker-plugin integration tests -->
        <invoker.skip>true</invoker.skip>
        <!-- Skip maven-archetype-plugin integration tests -->
        <archetype.test.skip>true</archetype.test.skip>
      </properties>
    </profile>

    <!-- profile used for building releases and deployment to sonatype/maven central -->
    <profile>
      <id>release-profile</id>
      <activation>
        <property>
          <name>performRelease</name>
          <value>true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <!-- sign the build -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <inherited>true</inherited>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <!-- configure staging process at sonatype.-->
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <inherited>true</inherited>
            <extensions>true</extensions>
            <configuration>
              <serverId>ossrh</serverId>
              <nexusUrl>https://oss.sonatype.org/</nexusUrl>
              <!-- Deployed artifacts should go to staging to be reviewed before publish -->
              <autoReleaseAfterClose>false</autoReleaseAfterClose>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. -->
    <profile>
      <id>only-eclipse</id>
      <activation>
        <property>
          <name>m2e.version</name>
        </property>
      </activation>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.eclipse.m2e</groupId>
              <artifactId>lifecycle-mapping</artifactId>
              <version>1.0.0</version>
              <configuration>
                <lifecycleMappingMetadata>
                  <pluginExecutions>
                    <pluginExecution>
                      <pluginExecutionFilter>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-plugin-plugin</artifactId>
                        <versionRange>[3.2,)</versionRange>
                        <goals>
                          <goal>descriptor</goal>
                          <goal>helpmojo</goal>
                        </goals>
                      </pluginExecutionFilter>
                      <action>
                        <ignore />
                      </action>
                    </pluginExecution>
                  </pluginExecutions>
                </lifecycleMappingMetadata>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
  </profiles>

  <distributionManagement>
    <site>
      <id>${site.deploy.id}</id>
      <name>Maven Site Deployment</name>
      <url>${site.deploy.url}</url>
    </site>
  </distributionManagement>

</project>
