<?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>
    <groupId>ru.progrm-jarvis</groupId>
    <artifactId>padla</artifactId>
    <version>1.0.0-rc.7</version>
    <modules>
        <module>java-commons</module>
        <module>reflector</module>
        <module>ultimate-messenger</module>
        <module>tools</module>
        <module>padla-bom</module>
    </modules>
    <packaging>pom</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version.minimal>8</java.version.minimal>
        <!-- Duplicated dependency versions -->
        <version.mockito>4.0.0</version.mockito>
    </properties>

    <name>PADLA for Java</name>
    <description>Pack of Java utilities for various needs</description>
    <url>https://padla.progrm-jarvis.ru/</url>

    <inceptionYear>2019</inceptionYear>

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

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

    <distributionManagement>
        <repository>
            <!-- This one is used for automatic sync with Maven Central -->
            <id>sonatype-ossrh</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
        <snapshotRepository>
            <id>sonatype-ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

    <developers>
        <developer>
            <id>progrm-jarvis</id>
            <name>JARvis PROgrammer (Peter P.)</name>
            <email>mrjarviscraft@gmail.com</email>
            <url>https://github.com/JarvisCraft</url>
            <roles>
                <role>Lead developer</role>
            </roles>
            <timezone>3</timezone>
            <properties>
                <social.vk>PROgrm_JARvis</social.vk>
                <social.twitter>PROgrm_JARvis</social.twitter>
                <social.telegram>PROgrm_JARvis</social.telegram>
            </properties>
        </developer>
    </developers>

    <build>
        <defaultGoal>verify install</defaultGoal>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.1</version>
                    <executions>
                        <execution>
                            <id>java-11</id>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                            <configuration>
                                <release>11</release>
                                <compileSourceRoots>
                                    <compileSourceRoot>${project.basedir}/src/main/java11</compileSourceRoot>
                                </compileSourceRoots>
                                <multiReleaseOutput>true</multiReleaseOutput>
                            </configuration>
                        </execution>
                        <execution>
                            <id>java-17</id>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                            <configuration>
                                <release>17</release>
                                <compileSourceRoots>
                                    <compileSourceRoot>${project.basedir}/src/main/java17</compileSourceRoot>
                                </compileSourceRoots>
                                <multiReleaseOutput>true</multiReleaseOutput>
                            </configuration>
                        </execution>
                    </executions>
                    <configuration>
                        <release>${java.version.minimal}</release>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.2.0</version>
                    <configuration>
                        <archive>
                            <manifestEntries>
                                <Multi-Release>true</Multi-Release>
                            </manifestEntries>
                        </archive>
                    </configuration>
                </plugin>
                <!-- Code-generation -->
                <plugin>
                    <groupId>org.apache.drill.tools</groupId>
                    <artifactId>drill-fmpp-maven-plugin</artifactId>
                    <version>1.19.0</version>
                    <executions>
                        <execution>
                            <id>generate-fmpp</id>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>generate</goal>
                            </goals>
                            <configuration>
                                <config>src/main/freemarker/config.fmpp</config>
                                <templates>src/main/freemarker/templates</templates>
                                <output>${project.build.directory}/generated-sources</output>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

                <!-- Testing -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.0.0-M5</version>
                    <configuration>
                        <parallel>all</parallel>
                        <useUnlimitedThreads>true</useUnlimitedThreads>
                    </configuration>
                </plugin>

                <!-- Maven-central deployment-related plugins -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>3.0.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.2.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>3.3.1</version>
                    <configuration>
                        <release>${java.version.minimal}</release>
                        <tags>
                            <tag>
                                <name>apiNote</name>
                                <placement>a</placement>
                                <head>API note</head>
                            </tag>
                            <tag>
                                <name>implNote</name>
                                <placement>a</placement>
                                <head>Implementation note</head>
                            </tag>
                            <tag>
                                <name>implSpec</name>
                                <placement>a</placement>
                                <head>Implementation specification</head>
                            </tag>
                        </tags>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.sonatype.plugins</groupId>
                    <artifactId>nexus-staging-maven-plugin</artifactId>
                    <version>1.6.8</version>
                    <extensions>true</extensions>
                    <configuration>
                        <serverId>sonatype-ossrh</serverId>
                        <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                        <autoReleaseAfterClose>true</autoReleaseAfterClose>
                    </configuration>
                    <dependencies>
                        <!-- Manual fix of Plugin crash on latest Java versions -->
                        <dependency>
                            <groupId>com.thoughtworks.xstream</groupId>
                            <artifactId>xstream</artifactId>
                            <version>1.4.17</version>
                        </dependency>
                        <dependency>
                            <groupId>org.ogce</groupId>
                            <artifactId>xpp3</artifactId>
                            <version>1.1.6</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <dependencyManagement>
        <dependencies>
            <!-- Own dependencies -->
            <dependency>
                <groupId>${project.groupId}</groupId>
                <artifactId>java-commons</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>${project.groupId}</groupId>
                <artifactId>reflector</artifactId>
                <version>${project.version}</version>
            </dependency>

            <!-- BOMs -->
            <dependency>
                <groupId>org.junit</groupId>
                <artifactId>junit-bom</artifactId>
                <version>5.8.1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <!-- Libraries -->
            <!-- Caching -->
            <dependency>
                <groupId>com.github.ben-manes.caffeine</groupId>
                <artifactId>caffeine</artifactId>
                <version>2.9.2</version>
                <scope>provided</scope>
                <optional>true</optional>
            </dependency>
            <!-- Bytecode generation -->
            <dependency>
                <groupId>org.ow2.asm</groupId>
                <artifactId>asm</artifactId>
                <version>9.2</version>
                <scope>provided</scope>
                <optional>true</optional>
            </dependency>
            <dependency>
                <groupId>org.javassist</groupId>
                <artifactId>javassist</artifactId>
                <version>3.28.0-GA</version>
                <scope>provided</scope>
                <optional>true</optional>
            </dependency>

            <!-- Code generation -->
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.18.22</version>
                <scope>provided</scope>
                <optional>true</optional>
            </dependency>

            <!-- Documenting -->
            <dependency>
                <groupId>org.jetbrains</groupId>
                <artifactId>annotations</artifactId>
                <version>22.0.0</version>
                <scope>provided</scope>
                <optional>true</optional>
            </dependency>

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

    <profiles>
        <profile>
            <id>build-extras</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <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>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>sign-artifacts</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>automatic-central-release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
