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

    <developers>
        <developer>
            <id>DarkAtra</id>
            <name>Tommy Schmidt</name>
            <email>darkatra@gmail.com</email>
            <url>https://github.com/DarkAtra</url>
            <roles>
                <role>maintainer</role>
            </roles>
        </developer>
    </developers>

    <licenses>
        <license>
            <name>MIT</name>
            <url>https://opensource.org/licenses/MIT</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <scm>
        <connection>scm:git:git@github.com:DarkAtra/bfme2-modding-utils.git</connection>
        <url>https://github.com/DarkAtra/bfme2-modding-utils</url>
    </scm>

    <distributionManagement>
        <repository>
            <id>github</id>
            <name>GitHub Packages</name>
            <url>https://maven.pkg.github.com/DarkAtra/bfme2-modding-utils</url>
        </repository>
    </distributionManagement>

    <groupId>de.darkatra.bfme2</groupId>
    <artifactId>bfme2-modding-utils</artifactId>
    <version>1.1.1</version>
    <packaging>pom</packaging>

    <name>${project.artifactId}</name>
    <description>A library that provides functions to read and write some of the EA file formats.</description>
    <url>https://github.com/DarkAtra/bfme2-modding-utils</url>

    <modules>
        <module>core</module>
        <module>refpack</module>
        <module>big</module>
        <module>map</module>
    </modules>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>

        <kotlin.code.style>official</kotlin.code.style>
        <kotlin.compiler.incremental>true</kotlin.compiler.incremental>

        <kotlin.version>2.3.0</kotlin.version>
        <java.version>17</java.version>

        <guava.version>33.5.0-jre</guava.version>
        <graalvm-hint.version>1.2.0</graalvm-hint.version>

        <assertj.version>3.27.6</assertj.version>
        <!-- Currently using an older version of JUnit 5 since GraalVM does not play nicely with the latest 5.x or 6.x releases -->
        <!-- * https://github.com/graalvm/native-build-tools/issues/695-->
        <!-- * https://github.com/graalvm/native-build-tools/issues/305-->
        <junit.version>5.12.2</junit.version>

        <maven-surefire-plugin.version>3.5.4</maven-surefire-plugin.version>
        <maven-source-plugin.version>3.4.0</maven-source-plugin.version>
        <dokka-maven-plugin.version>2.1.0</dokka-maven-plugin.version>
        <maven-gpg-plugin.version>3.2.8</maven-gpg-plugin.version>
        <central-publishing-maven-plugin.version>0.9.0</central-publishing-maven-plugin.version>
        <native-build-tools-plugin.version>0.10.3</native-build-tools-plugin.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- Kotlin -->
            <dependency>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-stdlib</artifactId>
                <version>${kotlin.version}</version>
            </dependency>
            <dependency>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-reflect</artifactId>
                <version>${kotlin.version}</version>
            </dependency>
            <dependency>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-test</artifactId>
                <version>${kotlin.version}</version>
                <scope>test</scope>
            </dependency>

            <!-- Project Versions -->
            <dependency>
                <groupId>de.darkatra.bfme2</groupId>
                <artifactId>big</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>de.darkatra.bfme2</groupId>
                <artifactId>core</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>de.darkatra.bfme2</groupId>
                <artifactId>refpack</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>de.darkatra.bfme2</groupId>
                <artifactId>map</artifactId>
                <version>${project.version}</version>
            </dependency>

            <!-- IO Utils and Data Structures -->
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>${guava.version}</version>
            </dependency>

            <!-- JUnit5 -->
            <dependency>
                <groupId>org.junit</groupId>
                <artifactId>junit-bom</artifactId>
                <version>${junit.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

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

    <dependencies>
        <!-- GraalVM Runtime Hint Annotations -->
        <dependency>
            <groupId>io.goodforgod</groupId>
            <artifactId>graalvm-hint-annotations</artifactId>
            <version>${graalvm-hint.version}</version>
            <scope>compile</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>io.goodforgod</groupId>
            <artifactId>graalvm-hint-processor</artifactId>
            <version>${graalvm-hint.version}</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>src/main/kotlin</sourceDirectory>
        <testSourceDirectory>src/test/kotlin</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <version>${kotlin.version}</version>
                <executions>
                    <execution>
                        <id>kapt</id>
                        <goals>
                            <goal>kapt</goal>
                        </goals>
                        <configuration>
                            <sourceDirs>
                                <sourceDir>src/main/kotlin</sourceDir>
                                <sourceDir>src/test/java</sourceDir>
                            </sourceDirs>
                            <annotationProcessorPaths>
                                <annotationProcessorPath>
                                    <groupId>io.goodforgod</groupId>
                                    <artifactId>graalvm-hint-processor</artifactId>
                                    <version>${graalvm-hint.version}</version>
                                </annotationProcessorPath>
                            </annotationProcessorPaths>
                        </configuration>
                    </execution>
                    <execution>
                        <id>compile</id>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <goals>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <jvmTarget>${java.version}</jvmTarget>
                    <args>
                        <arg>-Xjsr305=strict</arg>
                        <arg>-Xemit-jvm-type-annotations</arg>
                    </args>
                </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.jetbrains.dokka</groupId>
                <artifactId>dokka-maven-plugin</artifactId>
                <version>${dokka-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <phase>package</phase>
                        <goals>
                            <goal>javadocJar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven-surefire-plugin.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <id>sign-with-gpg</id>
            <build>
                <plugins>
                    <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>
                        <configuration>
                            <keyname>6AC5B1D7</keyname>
                            <gpgArguments>
                                <arg>--pinentry-mode</arg>
                                <arg>loopback</arg>
                            </gpgArguments>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>publish-central-portal</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>${central-publishing-maven-plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                            <autoPublish>true</autoPublish>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>nativeTest</id>
            <dependencies>
                <dependency>
                    <groupId>org.junit.platform</groupId>
                    <artifactId>junit-platform-launcher</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.graalvm.buildtools</groupId>
                        <artifactId>native-maven-plugin</artifactId>
                        <version>${native-build-tools-plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <classesDirectory>${project.build.outputDirectory}</classesDirectory>
                            <buildArgs combine.children="append">
                                <!-- Workaround for https://github.com/oracle/graal/issues/6957 -->
                                <arg>--strict-image-heap</arg>
                            </buildArgs>
                        </configuration>
                        <executions>
                            <execution>
                                <id>native-test</id>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
