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

  <version>1.0.0</version>
  <groupId>software.xdev</groupId>
  <artifactId>micro-migration</artifactId>
  <name>MicroMigration</name>
  <description>Multimodule project for Micro Migration</description>
  <packaging>pom</packaging>

  <inceptionYear>2021</inceptionYear>

  <url>https://github.com/xdev-software/micro-migration</url>
  <scm>
    <url>https://github.com/xdev-software/micro-migration</url>
    <connection>https://github.com/xdev-software/micro-migration.git</connection>
  </scm>

  <organization>
    <name>XDEV Software GmbH</name>
    <url>https://xdev.software</url>
  </organization>

  <developers>
    <developer>
      <name>XDEV Software GmbH</name>
      <organization>XDEV Software GmbH</organization>
      <url>https://xdev.software</url>
    </developer>
  </developers>

  <licenses>
    <license>
      <name>Apache License 2.0</name>
      <url>https://www.apache.org/licenses/LICENSE-2.0</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <!-- "Why only version 9?" - Because MicroStream is supporting Java 8 as lowest version,
    but we are using some functionality from Java 9:
    https://docs.microstream.one/manual/intro/system-requirements.html -->
    <java.version>9</java.version>
    <maven.version>3.8.1</maven.version>
    <maven.compiler.target>${java.version}</maven.compiler.target>
    <maven.compiler.release>${java.version}</maven.compiler.release>
  </properties>

  <modules>
    <module>core</module>
    <module>reflection</module>
    <module>examples</module>
    <module>microstream-v5</module>
    <module>microstream-v6</module>
    <module>microstream-v7</module>
    <module>microstream-v8</module>
    <module>eclipse-store-v1</module>
  </modules>

  <dependencies>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <version>5.10.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <version>5.10.0</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.3.1</version>
          <configuration>
            <encoding>UTF-8</encoding>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>3.5.0</version>
          <configuration>
            <source>${java.version}</source>
            <encoding>UTF-8</encoding>
            <detectJavaApiLink>false</detectJavaApiLink>
          </configuration>
          <executions>
            <execution>
              <id>attach-javadoc</id>
              <goals>
                <goal>jar</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>3.3.0</version>
          <executions>
            <execution>
              <id>attach-source</id>
              <goals>
                <goal>jar</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.jreleaser</groupId>
          <artifactId>jreleaser-maven-plugin</artifactId>
          <version>1.8.0</version>
          <configuration>
            <jreleaser>
              <signing>
                <active>ALWAYS</active>
                <armored>true</armored>
              </signing>
              <deploy>
                <maven>
                  <nexus2>
                    <maven-central>
                      <active>ALWAYS</active>
                      <url>https://s01.oss.sonatype.org/service/local</url>
                      <closeRepository>false</closeRepository>
                      <releaseRepository>false</releaseRepository>
                      <stagingRepositories>target/staging-deploy</stagingRepositories>
                    </maven-central>
                  </nexus2>
                </maven>
              </deploy>
            </jreleaser>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.11.0</version>
          <configuration>
            <source>${java.version}</source>
            <target>${java.version}</target>
            <encoding>UTF-8</encoding>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>

    <plugins>

      <!--
        Sorts the import-entries of the java-files.
        Is identical to the IntelliJ-Codestyle but provides some support if IntelliJ is not used.
      -->
      <plugin>
        <groupId>net.revelc.code</groupId>
        <artifactId>impsort-maven-plugin</artifactId>
        <version>1.9.0</version>
        <configuration>
          <groups>java.,javax.,org.,com.</groups>
          <staticGroups>java,*</staticGroups>
        </configuration>
        <executions>
          <execution>
            <id>sort-imports</id>
            <goals>
              <goal>sort</goal><!-- runs at process-sources phase by default -->
            </goals>
          </execution>
        </executions>
      </plugin>

      <!--
        From: https://github.com/gaul/modernizer-maven-plugin
          Modernizer Maven Plugin detects uses of legacy APIs which modern Java versions supersede.
          These modern APIs are often more performant, safer, and idiomatic than the legacy equivalents.
          For example, Modernizer can detect uses of Vector instead of ArrayList,
          String.getBytes(String) instead of String.getBytes(Charset), and Guava Objects.equal instead of Java 7 Objects.equals.
        Fails if it finds any violations.
      -->
      <plugin>
        <groupId>org.gaul</groupId>
        <artifactId>modernizer-maven-plugin</artifactId>
        <version>2.6.0</version>
        <configuration>
          <javaVersion>${java.version}</javaVersion>
        </configuration>
        <executions>
          <execution>
            <id>modernizer</id>
            <phase>verify</phase>
            <goals>
              <goal>modernizer</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- It's possible to enforce much more. See https://maven.apache.org/enforcer/enforcer-rules/index.html-->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>3.3.0</version>
        <executions>
          <!-- Enforces the usage of the correct Java and Maven version -->
          <execution>
            <id>enforce-maven-and-java</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <!-- Use at least the defined Maven version. Higher version is also acceptable. -->
                <requireMavenVersion>
                  <version>${maven.version}</version>
                </requireMavenVersion>
                <requireJavaVersion>
                  <version>${java.version}</version>
                </requireJavaVersion>
              </rules>
            </configuration>
          </execution>
          <!-- Enforces the UTF-8 coding -->
          <execution>
            <id>require-utf-8</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireEncoding>
                  <encoding>UTF-8</encoding>
                  <includes>*.java</includes>
                </requireEncoding>
              </rules>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <!-- Needed for enforcing UTF-8 -->
          <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>extra-enforcer-rules</artifactId>
            <version>1.7.0</version>
          </dependency>
        </dependencies>
      </plugin>

      <!--
          From https://github.com/policeman-tools/forbidden-apis:
          Allows to parse Java byte code to find invocations of method/class/field signatures and fail build.
      -->
      <plugin>
        <groupId>de.thetaphi</groupId>
        <artifactId>forbiddenapis</artifactId>
        <version>3.6</version>
        <configuration>
          <bundledSignatures>
            <!-- This will automatically choose the right signatures based on 'maven.compiler.target': -->
            <bundledSignature>jdk-unsafe</bundledSignature>
            <bundledSignature>jdk-deprecated</bundledSignature>
            <!-- disallow undocumented classes like sun.misc.Unsafe: -->
            <bundledSignature>jdk-non-portable</bundledSignature>
            <!-- don't allow unsafe reflective access: -->
            <bundledSignature>jdk-reflection</bundledSignature>
            <!--
              [ERROR] Forbidden field access: java.lang.System#out
              [prints to System.out; should only be used for debugging, not in production code]
            -->
            <bundledSignature>jdk-system-out</bundledSignature>
          </bundledSignatures>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>check</goal>
              <goal>testCheck</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- Creates an report about the failed checkstyle-rules. Throws error, if a checkstyle-rule is violated. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>3.3.0</version>
        <dependencies>
          <dependency>
            <groupId>com.puppycrawl.tools</groupId>
            <artifactId>checkstyle</artifactId>
            <version>10.9.3</version>
          </dependency>
        </dependencies>
        <configuration>
          <configLocation>config/checkstyle.xml</configLocation>
          <encoding>UTF-8</encoding>
          <consoleOutput>false</consoleOutput>
          <failsOnError>true</failsOnError>
          <linkXRef>false</linkXRef>
        </configuration>
        <executions>
          <execution>
            <id>validate</id>
            <phase>validate</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.1.2</version>
      </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-resources-plugin</artifactId>
      </plugin>

      <!-- Writes the license as a header in every java file. -->
      <plugin>
        <groupId>com.mycila</groupId>
        <artifactId>license-maven-plugin</artifactId>
        <version>4.3</version>
        <configuration>
          <properties>
            <email>${project.organization.url}</email>
          </properties>
          <licenseSets>
            <licenseSet>
              <header>com/mycila/maven/plugin/license/templates/APACHE-2.txt</header>
              <includes>
                <include>src/main/java/**</include>
                <include>src/test/java/**</include>
              </includes>
            </licenseSet>
          </licenseSets>
        </configuration>
        <executions>
          <execution>
            <id>first</id>
            <goals>
              <goal>format</goal>
            </goals>
            <phase>process-sources</phase>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.jreleaser</groupId>
            <artifactId>jreleaser-maven-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <configuration>
              <source>${java.version}</source>
              <encoding>UTF-8</encoding>
              <detectJavaApiLink>false</detectJavaApiLink>
              <!-- Don't throw ERRORs during build -->
              <additionalOptions>-Xdoclint:none</additionalOptions>
              <additionalJOption>-Xdoclint:none</additionalJOption>
            </configuration>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>aggregate-jar</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-source</id>
                <goals>
                  <goal>aggregate</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
