<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>io.microraft</groupId>
    <artifactId>microraft-root</artifactId>
    <packaging>pom</packaging>
    <version>0.7</version>

    <name>MicroRaft Root</name>
    <url>https://microraft.io</url>
    <description>Feature-complete implementation of the Raft consensus algorithm</description>

    <developers>
        <developer>
            <id>metanet</id>
            <name>Ensar Basri Kahveci</name>
            <email>ebkahveci@gmail.com</email>
        </developer>
        <developer>
            <id>mdogan</id>
            <name>Mehmet Dogan</name>
            <email>mehmet@dogan.io</email>
        </developer>
    </developers>

    <organization>
        <name>MicroRaft</name>
        <url>https://microraft.io/</url>
    </organization>

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

    <scm>
        <url>https://github.com/MicroRaft/MicroRaft</url>
        <connection>scm:git:git@github.com:MicroRaft/MicroRaft</connection>
        <developerConnection>scm:git:git@github.com:MicroRaft/MicroRaft.git</developerConnection>
    </scm>

    <issueManagement>
        <system>Github</system>
        <url>https://github.com/MicroRaft/MicroRaft/issues</url>
    </issueManagement>

    <modules>
        <module>microraft</module>
        <module>microraft-hocon</module>
        <module>microraft-yaml</module>
        <module>microraft-metrics</module>
        <module>microraft-store-sqlite</module>
        <module>microraft-tutorial</module>
    </modules>

    <properties>
        <root.dir>${project.basedir}</root.dir>
        <maven.build.timestamp.format>yyyy-MM-dd</maven.build.timestamp.format>
        <timestamp>${maven.build.timestamp}</timestamp>
        <jdk.version>11</jdk.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <vmHeapSettings>-Xms1G -Xmx2G</vmHeapSettings>
        <extraVmSettings/>

        <redirect.test.output.to.file>false</redirect.test.output.to.file>

        <slf4j.api.version>1.7.36</slf4j.api.version>
        <log4j.version>2.19.0</log4j.version>
        <junit.version>4.13.2</junit.version>
        <mockito.version>3.12.4</mockito.version>
        <assertj.version>3.23.1</assertj.version>
        <findbugs.annotations.version>3.0.1</findbugs.annotations.version>

        <surefire.fork.count>4</surefire.fork.count>

        <maven.compiler.plugin.version>3.10.1</maven.compiler.plugin.version>
        <maven.spotbugs.plugin.version>3.1.12.2</maven.spotbugs.plugin.version>
        <maven.surefire.plugin.version>2.22.2</maven.surefire.plugin.version>
        <maven.resources.plugin.version>3.2.0</maven.resources.plugin.version>
        <maven.source.plugin.version>3.2.1</maven.source.plugin.version>
        <maven.javadoc.plugin.version>3.2.0</maven.javadoc.plugin.version>
        <maven.jacoco.plugin.version>0.8.5</maven.jacoco.plugin.version>
        <maven.checkstyle.plugin.version>3.2.0</maven.checkstyle.plugin.version>
        <maven.formatter.plugin.version>2.21.0</maven.formatter.plugin.version>
        <maven.checksum.plugin.version>1.4</maven.checksum.plugin.version>
        <maven.install.plugin.version>3.1.0</maven.install.plugin.version>
        <nexus.staging.maven.plugin.version>1.6.13</nexus.staging.maven.plugin.version>
        <maven.gpg.plugin.version>1.6</maven.gpg.plugin.version>
    </properties>

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

        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>annotations</artifactId>
            <version>${findbugs.annotations.version}</version>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>

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

        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>${assertj.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
            <version>${log4j.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>${log4j.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>${log4j.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>net.ju-n.maven.plugins</groupId>
            <artifactId>checksum-maven-plugin</artifactId>
            <version>${maven.checksum.plugin.version}</version>
        </dependency>
    </dependencies>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <build>
        <resources>
            <resource>
                <directory>${root.dir}</directory>
                <includes>
                    <include>NOTICE*</include>
                    <include>LICENSE*</include>
                </includes>
            </resource>
        </resources>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>net.ju-n.maven.plugins</groupId>
                    <artifactId>checksum-maven-plugin</artifactId>
                    <version>${maven.checksum.plugin.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>artifacts</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <fileSets>
                            <fileSet>
                                <directory>${project.build.directory}</directory>
                                <includes>
                                    <include>*.jar</include>
                                </includes>
                            </fileSet>
                        </fileSets>
                        <algorithms>
                            <algorithm>SHA-1</algorithm>
                            <algorithm>MD5</algorithm>
                        </algorithms>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.plugin.version}</version>
                <configuration>
                    <source>${jdk.version}</source>
                    <target>${jdk.version}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.plugin.version}</version>
                <configuration>
                    <forkCount>${surefire.fork.count}</forkCount>
                    <reuseForks>false</reuseForks>
                    <runOrder>random</runOrder>
                    <argLine>
                        ${vmHeapSettings}
                        ${extraVmSettings}
                        -ea
                    </argLine>
                    <redirectTestOutputToFile>${redirect.test.output.to.file}</redirectTestOutputToFile>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>${maven.resources.plugin.version}</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>${maven.source.plugin.version}</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>${maven.javadoc.plugin.version}</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <encoding>${project.build.sourceEncoding}</encoding>
                    <source>${jdk.version}</source>
                    <sourcepath>src/main/java</sourcepath>
                    <excludePackageNames>io.microraft.model.*:*.impl:*.impl.*</excludePackageNames>
                </configuration>
            </plugin>

            <plugin>
                <groupId>net.revelc.code.formatter</groupId>
                <artifactId>formatter-maven-plugin</artifactId>
                <version>${maven.formatter.plugin.version}</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <compilerSource>${jdk.version}</compilerSource>
                    <compilerTargetPlatform>${jdk.version}</compilerTargetPlatform>
                    <configFile>${maven.multiModuleProjectDirectory}/tools/formatter.xml</configFile>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>format</goal>
                            <!-- <goal>validate</goal> -->
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-install-plugin</artifactId>
                <version>${maven.install.plugin.version}</version>
                <configuration>
                    <createChecksum>true</createChecksum>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>${nexus.staging.maven.plugin.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <serverId>ossrh</serverId>
                    <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
                    <autoReleaseAfterClose>true</autoReleaseAfterClose>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>${maven.gpg.plugin.version}</version>
                <executions>
                    <execution>
                        <id>sign-artifacts</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>spotbugs</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.spotbugs</groupId>
                        <artifactId>spotbugs-maven-plugin</artifactId>
                        <version>${maven.spotbugs.plugin.version}</version>
                        <executions>
                            <execution>
                                <phase>compile</phase>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <excludeFilterFile>${root.dir}/tools/spotbugs-ignore.xml</excludeFilterFile>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>checkstyle</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-checkstyle-plugin</artifactId>
                        <version>${maven.checkstyle.plugin.version}</version>
                        <executions>
                            <execution>
                                <id>validate</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <configLocation>${root.dir}/tools/checkstyle.xml</configLocation>
                            <suppressionsLocation>${root.dir}/tools/checkstyle-suppressions.xml</suppressionsLocation>
                            <consoleOutput>true</consoleOutput>
                            <failsOnError>true</failsOnError>
                            <failOnViolation>true</failOnViolation>
                            <includeTestSourceDirectory>true</includeTestSourceDirectory>
                            <enableRulesSummary>true</enableRulesSummary>
                            <propertyExpansion>basedir=${root.dir}</propertyExpansion>
                            <sourceDirectories>
                                <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
                                <sourceDirectory>${project.build.testSourceDirectory}</sourceDirectory>
                            </sourceDirectories>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>coverage</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${maven.surefire.plugin.version}</version>
                        <configuration>
                            <forkCount>2</forkCount>
                            <reuseForks>true</reuseForks>
                            <runOrder>random</runOrder>
                            <argLine>
                                @{argLine}
                                ${vmHeapSettings}
                                ${extraVmSettings}
                                -ea
                            </argLine>
                            <redirectTestOutputToFile>${redirect.test.output.to.file}</redirectTestOutputToFile>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>${maven.jacoco.plugin.version}</version>
                        <executions>
                            <execution>
                                <id>default-prepare-agent</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>default-report</id>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>report</id>
                                <phase>test</phase>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>tutorial</id>
            <properties>
                <redirect.test.output.to.file>false</redirect.test.output.to.file>
            </properties>
        </profile>
    </profiles>

</project>
