<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>com.github.almasb</groupId>
    <artifactId>fxgl-framework</artifactId>
    <version>17.2</version>
    
    <packaging>pom</packaging>

    <name>${project.groupId}:${project.artifactId}</name>
    <description>JavaFX Game Development Framework</description>
    <url>http://almasb.github.io/FXGL/</url>

    <modules>
        <module>fxgl-core</module>
        <module>fxgl-io</module>
        <module>fxgl-entity</module>
        <module>fxgl-scene</module>
        <module>fxgl</module>
        <module>fxgl-test</module>
        <module>fxgl-controllerinput</module>
        <module>fxgl-gameplay</module>
        <module>fxgl-samples</module>
        <module>fxgl-tools</module>
        <module>fxgl-zdeploy</module>
    </modules>

    <licenses>
        <license>
            <name>MIT License</name>
            <url>http://www.opensource.org/licenses/mit-license.php</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <scm>
        <url>https://github.com/AlmasB/FXGL</url>
        <connection>scm:git:git://github.com/AlmasB/FXGL.git</connection>
        <developerConnection>scm:git:git@github.com:AlmasB/FXGL.git</developerConnection>
    </scm>

    <developers>
        <developer>
            <email>almaslvl@gmail.com</email>
            <name>Almas Baimagambetov</name>
            <url>https://github.com/AlmasB</url>
            <id>almasb</id>
        </developer>
    </developers>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <issueManagement>
        <url>https://github.com/AlmasB/FXGL/issues</url>
        <system>GitHub Issues</system>
    </issueManagement>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <source.version>17</source.version>
        <fxgl.version>${project.version}</fxgl.version>

        <timestamp>${maven.build.timestamp}</timestamp>
        <maven.build.timestamp.format>dd.MM.yyyy HH.mm</maven.build.timestamp.format>

        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <kotlin.compiler.jvmTarget>11</kotlin.compiler.jvmTarget>
        <kotlin.compiler.incremental>true</kotlin.compiler.incremental>

        <!-- plugins -->
        <maven.gpg.version>1.6</maven.gpg.version>
        <sonatype.nexus.staging.version>1.6.8</sonatype.nexus.staging.version>
        <maven.compiler.version>3.8.0</maven.compiler.version>
        <maven.pmd.version>3.15.0</maven.pmd.version>
        <maven.license.version>3.0</maven.license.version>
        <maven.source.version>3.2.0</maven.source.version>
        <maven.jar.version>3.2.0</maven.jar.version>
        <maven.shade.version>3.2.2</maven.shade.version>
        <jacoco.version>0.8.7</jacoco.version>
        <maven.surefire.version>3.0.0-M4</maven.surefire.version>
        <build.helper.version>3.0.0</build.helper.version>
        <maven.templating.version>1.0.0</maven.templating.version>

        <!-- dependencies -->
        <jfx.version>18</jfx.version>
        <kotlin.version>1.6.0</kotlin.version>
        <attach.version>4.0.13</attach.version>
        <jackson.version>2.12.1</jackson.version>

        <!-- test dependencies -->
        <junit.jupiter.version>5.8.2</junit.jupiter.version>
        <junit.platform.version>1.8.2</junit.platform.version>
        <hamcrest.version>1.3</hamcrest.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib</artifactId>
            <version>${kotlin.version}</version>
            <classifier>modular</classifier>
        </dependency>

        <!-- test scope dependencies -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <version>${hamcrest.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>

                <!-- Compile java -->
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven.compiler.version}</version>
                    <configuration>
                        <release>${source.version}</release>
                        <compilerArgs>
                            <arg>--module-version</arg>
                            <arg>${project.version}</arg>
                        </compilerArgs>
                    </configuration>
                </plugin>

                <!-- Compile kotlin -->
                <plugin>
                    <groupId>org.jetbrains.kotlin</groupId>
                    <artifactId>kotlin-maven-plugin</artifactId>
                    <version>${kotlin.version}</version>
                    <executions>
                        <execution>
                            <id>compile</id>
                            <phase>process-sources</phase>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                            <configuration>
                                <sourceDirs>
                                    <source>src/main/kotlin</source>
                                    <source>src/main/java</source>
                                </sourceDirs>
                            </configuration>
                        </execution>
                        <execution>
                            <id>test-compile</id>
                            <phase>process-test-sources</phase>
                            <goals>
                                <goal>test-compile</goal>
                            </goals>
                            <configuration>
                                <sourceDirs>
                                    <source>src/test/kotlin</source>
                                    <source>src/test/java</source>
                                </sourceDirs>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

                <!-- Create sources.jar -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>${maven.source.version}</version>
                    <executions>
                        <execution>
                            <id>attach-sources</id>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <!-- Create empty javadoc.jar -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>${maven.jar.version}</version>
                    <executions>
                        <execution>
                            <id>empty-javadoc-jar</id>
                            <phase>package</phase>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                            <configuration>
                                <classifier>javadoc</classifier>
                                <classesDirectory>${basedir}/javadoc</classesDirectory>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

                <!-- Add kotlin sources -->
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>${build.helper.version}</version>

                    <executions>
                        <execution>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>add-source</goal>
                            </goals>
                            <configuration>
                                <sources>
                                    <source>src/main/kotlin</source>
                                </sources>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <!-- Check code quality -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>${maven.pmd.version}</version>
                <configuration>
                    <sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
                    <targetJdk>${maven.compiler.target}</targetJdk>
                    <verbose>true</verbose>
                    <linkXRef>false</linkXRef>
                </configuration>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Check license headers -->
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>${maven.license.version}</version>
                <configuration>
                    <header>LICENSE_HEADER</header>
                    <strictCheck>false</strictCheck>
                    <includes>
                        <include>**/*.java</include>
                        <include>**/*.kt</include>
                    </includes>
                    <excludes>
                        <exclude>src/test/**</exclude>
                    </excludes>
                </configuration>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Sign artifact using gpg -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>${maven.gpg.version}</version>
                <executions>
                    <execution>
                        <id>sign-artifacts</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>


                    </execution>
                </executions>
            </plugin>

            <!-- Upload to sonatype nexus / maven central -->
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>${sonatype.nexus.staging.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <serverId>ossrh</serverId>
                    <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                    <autoReleaseAfterClose>true</autoReleaseAfterClose>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.version}</version>
            </plugin>
        </plugins>
    </build>
</project>