<?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>fr.luc</groupId>
    <artifactId>CR-Core</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>CR-Core</name>
    <description>Reusable core library for CR Minecraft game plugins (teams, players, scores, commands, events, SQLite persistence).</description>

    <properties>
        <maven.compiler.source>16</maven.compiler.source>
        <maven.compiler.target>16</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <sqlite.version>3.45.3.0</sqlite.version>
    </properties>

    <repositories>
        <repository>
            <id>papermc</id>
            <url>https://repo.papermc.io/repository/maven-public/</url>
        </repository>
        <repository>
            <id>spigot-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
        </repository>
        <repository>
            <id>sonatype</id>
            <url>https://oss.sonatype.org/content/groups/public/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>com.destroystokyo.paper</groupId>
            <artifactId>paper-api</artifactId>
            <version>1.16.5-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <!--
            SQLite JDBC driver. Scope compile so consumer plugins that depend on
            CR-Core get it transitively. They are expected to shade it into
            their final jar (or declare the dependency themselves) since Paper
            does not bundle it.
        -->
        <dependency>
            <groupId>org.xerial</groupId>
            <artifactId>sqlite-jdbc</artifactId>
            <version>${sqlite.version}</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

    <!--
        Publication vers le registry Maven de Gitea (Gitea Packages).
        URL = https://<gitea>/api/packages/<owner>/maven
        Le même endpoint sert pour les releases et les snapshots ; Gitea
        décide selon le suffixe -SNAPSHOT de la version.

        L'<id> doit matcher l'entrée <server id="gitea-luc-rival"> dans
        ~/.m2/settings.xml (qui contient le PAT). Voir docs/setup.md.
    -->
    <distributionManagement>
        <repository>
            <id>gitea-luc-rival</id>
            <url>https://gitea.luc-rival.fr/api/packages/admin/maven</url>
        </repository>
        <snapshotRepository>
            <id>gitea-luc-rival</id>
            <url>https://gitea.luc-rival.fr/api/packages/admin/maven</url>
        </snapshotRepository>
    </distributionManagement>

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

            <!--
                Publie un -sources.jar contenant le code source .java. Permet à
                IntelliJ d'aller au source d'une classe CR-Core depuis un plugin
                de jeu consommateur (Ctrl+Click).
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!--
                Publie un -javadoc.jar contenant le HTML généré à partir des
                commentaires /** ... */ du code. IntelliJ l'affiche en popup
                au survol d'une méthode CR-Core.

                doclint=none désactive les checks stricts (méthodes sans @param,
                @return, etc.) — on accepte de la doc partielle plutôt que
                bloquer le build.
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.6.3</version>
                <configuration>
                    <source>${maven.compiler.source}</source>
                    <doclint>none</doclint>
                    <quiet>true</quiet>
                    <encoding>UTF-8</encoding>
                    <docencoding>UTF-8</docencoding>
                    <charset>UTF-8</charset>
                    <failOnError>false</failOnError>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
