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

    <name>Nukkit-MOT</name>
    <groupId>cn.nukkit</groupId>
    <artifactId>Nukkit</artifactId>
    <version>MOT-SNAPSHOT</version>
    <description>Minecraft Bedrock Edition server software supporting multi-version clients and NetEase clients.</description>
    <url>https://www.nukkit-mot.com/</url>

    <licenses>
        <license>
            <name>GNU Lesser General Public License, version 3</name>
            <url>https://www.gnu.org/licenses/lgpl-3.0.txt</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>MemoriesOfTime</name>
            <organization>MemoriesOfTime</organization>
            <organizationUrl>https://github.com/MemoriesOfTime</organizationUrl>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git://github.com/MemoriesOfTime/Nukkit-MOT.git</connection>
        <developerConnection>scm:git:ssh://github.com:MemoriesOfTime/Nukkit-MOT.git</developerConnection>
        <url>https://github.com/MemoriesOfTime/Nukkit-MOT</url>
    </scm>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <log4j2.version>2.26.1</log4j2.version>
        <lombok.version>1.18.46</lombok.version>
        <maven.compiler.plugin.version>3.15.0</maven.compiler.plugin.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
        <argLine></argLine>
        <jline.version>3.30.15</jline.version>
        <leveldb-mcpe-java.version>1.1.0</leveldb-mcpe-java.version>
        <leveldb-mcpe-jni.version>0.0.12</leveldb-mcpe-jni.version>
        <block-state-updater.version>1.21.110-20250915.183018-1</block-state-updater.version>
        <netty.version>4.2.20.Final</netty.version>
        <maven.shade.skip>false</maven.shade.skip>
        <!-- 分配/性能测量默认不进入 mvn test；-Pperf 反向选择 perf 标签 -->
        <test.groups></test.groups>
        <test.excludedGroups>perf</test.excludedGroups>
        <!-- Reproducible build: entry timestamps follow the last commit time -->
        <project.build.outputTimestamp>${git.commit.time}</project.build.outputTimestamp>
    </properties>

    <distributionManagement>
        <snapshotRepository>
            <id>repo-lanink-cn</id>
            <url>https://repo.lanink.cn/repository/maven-snapshots/</url>
        </snapshotRepository>
        <repository>
            <id>repo-lanink-cn</id>
            <url>https://repo.lanink.cn/repository/maven-releases/</url>
        </repository>
    </distributionManagement>

    <repositories>
        <repository>
            <id>central</id>
            <url>https://repo.maven.apache.org/maven2</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>opencollab-repo-release</id>
            <url>https://repo.opencollab.dev/maven-releases/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>opencollab-repo-snapshot</id>
            <url>https://repo.opencollab.dev/maven-snapshots/</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>mot-repository-maven-releases</id>
            <url>https://repo.lanink.cn/repository/maven-releases</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>mot-repository-maven-snapshots</id>
            <url>https://repo.lanink.cn/repository/maven-snapshots</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>okaeri-releases</id>
            <url>https://repo.okaeri.cloud/releases</url>
        </repository>
        <repository>
            <id>porklib-maven</id>
            <url>https://maven.daporkchop.net/</url>
        </repository>
    </repositories>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.google.errorprone</groupId>
                <artifactId>error_prone_annotations</artifactId>
                <version>2.41.0</version>
            </dependency>
            <!-- libdatachannel 与 raknet/oshi 传递依赖版本分叉，统一固定；Pin diverging transitive versions -->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>2.0.18</version>
            </dependency>
            <dependency>
                <groupId>net.jodah</groupId>
                <artifactId>expiringmap</artifactId>
                <version>0.5.11</version>
            </dependency>
            <dependency>
                <groupId>org.jspecify</groupId>
                <artifactId>jspecify</artifactId>
                <version>1.0.1</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.cloudburstmc.netty</groupId>
            <artifactId>netty-transport-nethernet</artifactId>
            <version>2.0.0.CR6-20261115.174122-26</version>
            <scope>compile</scope>
            <exclusions>
                <!-- 统一使用服务器自带的 Netty 4.2.x；Use the Netty version this server ships with (4.2.x) -->
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
                <!-- 改用下方 arch-detect：自带全部平台原生库；Use arch-detect below, it bundles every platform's natives -->
                <exclusion>
                    <groupId>dev.opencollab</groupId>
                    <artifactId>libdatachannel-java</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.cloudburstmc.netty</groupId>
            <artifactId>netty-transport-common</artifactId>
            <version>2.0.0.CR6-20261115.174122-26</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-transport</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>dev.opencollab</groupId>
            <artifactId>libdatachannel-java</artifactId>
            <version>0.24.6.0-20261105.085043-11</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>dev.opencollab</groupId>
            <artifactId>libdatachannel-java-arch-detect</artifactId>
            <version>0.24.6.0-20261105.085043-11</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <groupId>dev.opencollab</groupId>
                    <artifactId>libdatachannel-java</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>dev.mot.netty</groupId>
            <artifactId>netty-transport-raknet</artifactId>
            <version>1.1.0.CR4-20261026.103812-1</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <groupId>dev.mot.netty</groupId>
                    <artifactId>netty-transport-common</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-common</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-codec-base</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-buffer</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-transport</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-transport-native-unix-common</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-codec-haproxy</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-transport-native-epoll</artifactId>
            <version>${netty.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-codec-http</artifactId>
            <version>${netty.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-codec-haproxy</artifactId>
            <version>${netty.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-handler</artifactId>
            <version>${netty.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.nukkitx</groupId>
            <artifactId>natives</artifactId>
            <version>1.0.3</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.cloudburstmc.protocol</groupId>
            <artifactId>common</artifactId>
            <version>3.0.0.Beta14-20261006.183140-3</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.cloudburstmc.math</groupId>
                    <artifactId>immutable</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-buffer</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.cloudburstmc.fastutil.maps</groupId>
                    <artifactId>int-object-maps</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.cloudburstmc.fastutil.maps</groupId>
                    <artifactId>object-int-maps</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>it.unimi.dsi</groupId>
            <artifactId>fastutil</artifactId>
            <version>8.5.15</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>33.7.2-jre</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <groupId>com.google.errorprone</groupId>
                    <artifactId>error_prone_annotations</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.checkerframework</groupId>
            <artifactId>checker-qual</artifactId>
            <version>3.42.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.13.2</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <groupId>com.google.errorprone</groupId>
                    <artifactId>error_prone_annotations</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.github.ben-manes.caffeine</groupId>
            <artifactId>caffeine</artifactId>
            <version>3.2.3</version>
            <exclusions>
                <exclusion>
                    <groupId>org.checkerframework</groupId>
                    <artifactId>checker-qual</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.errorprone</groupId>
                    <artifactId>error_prone_annotations</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
            <version>2.5</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.snakeyaml</groupId>
            <artifactId>snakeyaml-engine</artifactId>
            <version>2.9</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-toml</artifactId>
            <version>2.20.1</version>
            <scope>compile</scope>
            <!--<exclusions>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-databind</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-core</artifactId>
                </exclusion>
            </exclusions>-->
        </dependency>
        <dependency>
            <groupId>eu.okaeri</groupId>
            <artifactId>okaeri-configs-yaml-snakeyaml</artifactId>
            <version>6.1.0-beta.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.nimbusds</groupId>
            <artifactId>nimbus-jose-jwt</artifactId>
            <version>10.9</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.ow2.asm</groupId>
            <artifactId>asm</artifactId>
            <version>9.9.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>${log4j2.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>${log4j2.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j2-impl</artifactId>
            <version>${log4j2.version}</version>
            <scope>runtime</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>net.minecrell</groupId>
            <artifactId>terminalconsoleappender</artifactId>
            <version>1.3.0</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.jline</groupId>
                    <artifactId>jline-reader</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.jline</groupId>
                    <artifactId>jline-terminal-jna</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.jline</groupId>
                    <artifactId>jline-terminal</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.jline</groupId>
            <artifactId>jline-terminal-jni</artifactId>
            <version>${jline.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.jline</groupId>
            <artifactId>jline-reader</artifactId>
            <version>${jline.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>jsr305</artifactId>
            <version>3.0.2</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.iq80.snappy</groupId>
            <artifactId>snappy</artifactId>
            <version>0.5</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.hivemc.leveldb</groupId>
            <artifactId>leveldb</artifactId>
            <version>${leveldb-mcpe-java.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.hivemc.leveldb</groupId>
            <artifactId>leveldb-api</artifactId>
            <version>${leveldb-mcpe-java.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>dev.mot.leveldb</groupId>
            <artifactId>leveldb-mcpe-jni</artifactId>
            <version>${leveldb-mcpe-jni.version}</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <groupId>com.hivemc.leveldb</groupId>
                    <artifactId>leveldb</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.hivemc.leveldb</groupId>
                    <artifactId>leveldb-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.guava</groupId>
                    <artifactId>guava</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-buffer</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>net.daporkchop.lib</groupId>
                    <artifactId>natives</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.iq80.snappy</groupId>
                    <artifactId>snappy</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>net.daporkchop.lib</groupId>
            <artifactId>natives</artifactId>
            <version>0.5.9-20250718.163325-7</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-buffer</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.sentry</groupId>
            <artifactId>sentry</artifactId>
            <version>6.25.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-math3</artifactId>
            <version>3.6.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.xerial.snappy</groupId>
            <artifactId>snappy-java</artifactId>
            <version>1.1.10.12</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.github.oshi</groupId>
            <artifactId>oshi-core</artifactId>
            <version>6.6.5</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.jetbrains</groupId>
            <artifactId>annotations</artifactId>
            <version>26.0.2</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.bitbucket.b_c</groupId>
            <artifactId>jose4j</artifactId>
            <version>0.9.6</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.cloudburstmc</groupId>
            <artifactId>block-state-updater</artifactId>
            <version>${block-state-updater.version}</version>
            <scope>compile</scope>
            <!--jackson-dataformat-toml导入新版依赖-->
            <exclusions>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-databind</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.10.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.10.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-launcher</artifactId>
            <version>1.10.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>5.23.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <version>5.23.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.bytebuddy</groupId>
            <artifactId>byte-buddy</artifactId>
            <version>1.18.8</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.bytebuddy</groupId>
            <artifactId>byte-buddy-agent</artifactId>
            <version>1.18.8</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.objenesis</groupId>
            <artifactId>objenesis</artifactId>
            <version>3.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.cloudburstmc.protocol</groupId>
            <artifactId>bedrock-codec</artifactId>
            <version>3.0.0.Beta14-20261006.183140-3</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-buffer</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.cloudburstmc.math</groupId>
            <artifactId>immutable</artifactId>
            <version>2.0-20220327.162752-1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>dev.mot.protocol</groupId>
            <artifactId>netease-protocol-extension</artifactId>
            <version>1.21.124-R1</version>
            <scope>test</scope>
        </dependency>
        <!-- Test -->
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.5.0</version>
                <configuration>
                    <excludes>
                        <exclude>cn/nukkit/buildtools/**</exclude>
                    </excludes>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>cn.nukkit.Bootstrap</mainClass>
                        </manifest>
                        <!-- MR-JAR：允许 META-INF/versions/21 的虚拟线程覆盖类在 JVM 21+ 生效
                             MR-JAR: activates META-INF/versions/21 overrides on JVM 21+ -->
                        <manifestEntries>
                            <Multi-Release>true</Multi-Release>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.plugin.version}</version>
                <configuration>
                    <release>${maven.compiler.target}</release>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                        <path>
                            <groupId>org.apache.logging.log4j</groupId>
                            <artifactId>log4j-core</artifactId>
                            <version>${log4j2.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
                <executions>
                    <!-- MR-JAR：src/main/java21 以 release 21 单独编译进 META-INF/versions/21，
                         仅允许 Java 21+ API（虚拟线程）；JVM 21+ 类加载器自动选中，17 自动忽略。
                         须跑在 default-compile 之后（依赖已编译的主类作 classpath）。
                         MR-JAR: compiles src/main/java21 at release 21 into META-INF/versions/21;
                         JVM 21+ picks these classes automatically, 17 ignores them. Must run
                         after default-compile (needs main classes on the classpath). -->
                    <execution>
                        <id>compile-java21</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <release>21</release>
                            <compileSourceRoots>
                                <compileSourceRoot>${project.basedir}/src/main/java21</compileSourceRoot>
                            </compileSourceRoots>
                            <outputDirectory>${project.build.outputDirectory}/META-INF/versions/21</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <id>add-build-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${project.basedir}/src/build-tools/java</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.5.5</version>
                <configuration>
                    <!-- 隐式异常（NPE/AIOOBE）不走 fast-throw 预分配，测试才可比异常消息文本 -->
                    <!-- Keep implicit-exception messages intact so tests can compare them -->
                    <argLine>@{argLine} -XX:-OmitStackTraceInFastThrow -javaagent:${org.mockito:mockito-core:jar}</argLine>
                    <groups>${test.groups}</groups>
                    <excludedGroups>${test.excludedGroups}</excludedGroups>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.7.0</version>
                <!-- 快照按实际解析的时间戳文件名复制，与 DEPENDENCIES.txt / Class-Path 的精确 pin 对齐；
                     仅作用于手动执行 dependency:copy-dependencies 预置的 lib/，使其可被引导直接判定就绪
                     Copies snapshots under resolved timestamped names matching the exact pins; applies to
                     manually invoked dependency:copy-dependencies so a pre-populated lib/ verifies as ready -->
                <configuration>
                    <useBaseVersion>false</useBaseVersion>
                </configuration>
                <executions>
                    <execution>
                        <id>test-dependency-properties</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>properties</goal>
                        </goals>
                    </execution>
                    <!-- 运行时依赖清单输入，供 GenerateDependencyManifest 生成 DEPENDENCIES.txt
                         Feeds GenerateDependencyManifest with the runtime dependency list -->
                    <execution>
                        <id>runtime-dependency-list</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>list</goal>
                        </goals>
                        <configuration>
                            <includeScope>runtime</includeScope>
                            <outputFile>${project.build.directory}/dependency-list.txt</outputFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!-- Minify every .json resource in the build output to shrink the JAR.
                     Source files stay readable; only the copied artifacts under target/classes are minified.
                     Runs in process-classes (after compile, before package) so the helper class is compiled,
                     and after the default process-resources copy. Idempotent: already-minified files are unchanged.
                     Uses Gson (compile classpath) to parse and re-serialize without whitespace. -->
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <id>minify-json-resources</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>cn.nukkit.buildtools.MinifyJsonResources</mainClass>
                            <arguments>
                                <argument>${project.build.outputDirectory}</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <!-- 生成 target/classes/DEPENDENCIES.txt，随 package 进 jar 供 Bootstrap 使用
                         Emits target/classes/DEPENDENCIES.txt, packaged for Bootstrap -->
                    <execution>
                        <id>generate-dependency-manifest</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>cn.nukkit.buildtools.GenerateDependencyManifest</mainClass>
                            <arguments>
                                <argument>${project.build.directory}/dependency-list.txt</argument>
                                <argument>${project.build.outputDirectory}/DEPENDENCIES.txt</argument>
                                <argument>${settings.localRepository}</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.6.2</version>
                <executions>
                    <execution>
                        <id>enforce</id>
                        <configuration>
                            <rules>
                                <DependencyConvergence />
                            </rules>
                        </configuration>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.6.2</version>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.logging.log4j</groupId>
                        <artifactId>log4j-transform-maven-shade-plugin-extensions</artifactId>
                        <version>0.2.0</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <skip>${maven.shade.skip}</skip>
                    <filters>
                        <filter>
                            <artifact>*:*</artifact>
                            <!-- META-INF/versions 不再整体排除：本项目 versions/21 的虚拟线程覆盖类
                                 需进入 shaded jar。放开后 bouncycastle(9/11/15/17/25)与 jackson-core(21)
                                 的版本化类同时激活——与 Gradle 构建（本就保留）及 Lite jar 路径（依赖
                                 自带 MR 标志）对齐，消除 Maven fat jar 此前的静默降级。
                                 META-INF/versions is intentionally kept: our versions/21
                                 virtual-thread overrides must reach the shaded jar. This also
                                 activates versioned classes from bouncycastle (9/11/15/17/25) and
                                 jackson-core (21), aligning the Maven fat jar with the Gradle build
                                 (which always kept them) and the Lite path (deps are MR-flagged
                                 themselves). -->
                            <excludes>
                                <exclude>META-INF/*.SF</exclude>
                                <exclude>META-INF/*.DSA</exclude>
                                <exclude>META-INF/*.RSA</exclude>
                                <exclude>module-info.class</exclude>
                            </excludes>
                        </filter>
                        <!-- Exclude build-time helper classes from the shaded JAR.
                             MinifyJsonResources only runs during process-classes. -->
                        <filter>
                            <artifact>${project.groupId}:${project.artifactId}</artifact>
                            <excludes>
                                <exclude>cn/nukkit/buildtools/**</exclude>
                            </excludes>
                        </filter>
                    </filters>
                    <transformers>
                        <transformer
                                implementation="org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer">
                        </transformer>
                        <!-- shaded jar 保持自包含：显式固定 Main-Class，避免继承 jar 插件清单的 Bootstrap 入口
                             Pin Main-Class so the shaded jar stays self-contained -->
                        <transformer
                                implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                            <mainClass>cn.nukkit.Nukkit</mainClass>
                            <manifestEntries>
                                <Multi-Release>true</Multi-Release>
                            </manifestEntries>
                        </transformer>
                    </transformers>
                    <createDependencyReducedPom>false</createDependencyReducedPom>
                </configuration>
            </plugin>
            <plugin>
                <!-- shade 把 thin jar 留成 original-<finalName>.jar，改名 <finalName>-Lite.jar 作为引导
                     自动下载发行版（original- 前缀匹配不到 CI 的 Nukkit-*.jar 归档通配）；
                     shade 被跳过（central-release）时无此文件，failonerror=false 容忍
                     Rename the shade leftover to the Lite flavor; failonerror=false tolerates
                     its absence when shading is skipped -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <id>rename-thin-jar-to-lite</id>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                    <move file="${project.build.directory}/original-${project.build.finalName}.jar"
                                          tofile="${project.build.directory}/${project.build.finalName}-Lite.jar"
                                          failonerror="false"/>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>pl.project13.maven</groupId>
                <artifactId>git-commit-id-plugin</artifactId>
                <version>4.9.10</version>
                <executions>
                    <execution>
                        <id>get-the-git-infos</id>
                        <goals>
                            <goal>revision</goal>
                        </goals>
                    </execution>
                </executions>

                <configuration>
                    <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
                    <prefix>git</prefix>
                    <dateFormat>yyyy-MM-dd'T'HH:mm:ssXXX</dateFormat>
                    <dateFormatTimeZone>UTC</dateFormatTimeZone>
                    <verbose>true</verbose>
                    <generateGitPropertiesFile>true</generateGitPropertiesFile>
                    <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties
                    </generateGitPropertiesFilename>
                    <format>properties</format>
                    <skipPoms>true</skipPoms>
                    <injectAllReactorProjects>false</injectAllReactorProjects>
                    <failOnNoGitDirectory>false</failOnNoGitDirectory>
                    <failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
                    <skip>false</skip>
                    <runOnlyOnce>true</runOnlyOnce>
                    <!-- Only commit-determined fields; the rest vary with the build
                         environment. git.commit.time must stay listed: this filter also
                         drops injected properties, and outputTimestamp resolves against
                         it (see dateFormat below). -->
                    <includeOnlyProperties>
                        <includeOnlyProperty>^git.commit.id.abbrev$</includeOnlyProperty>
                        <includeOnlyProperty>^git.commit.time$</includeOnlyProperty>
                        <includeOnlyProperty>^git.branch$</includeOnlyProperty>
                    </includeOnlyProperties>
                    <useBranchNameFromBuildEnvironment>false</useBranchNameFromBuildEnvironment>
                    <useNativeGit>false</useNativeGit>
                    <abbrevLength>7</abbrevLength>
                    <commitIdGenerationMode>flat</commitIdGenerationMode>
                    <gitDescribe>
                        <skip>false</skip>
                        <always>false</always>
                        <abbrev>7</abbrev>
                        <dirty>-dirty</dirty>
                        <match>*</match>
                        <tags>false</tags>
                        <forceLongFormat>false</forceLongFormat>
                    </gitDescribe>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.12.0</version>
                <configuration>
                    <doclint>all,-missing</doclint>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.4.0</version>
                <configuration>
                    <excludes>
                        <exclude>cn/nukkit/buildtools/**</exclude>
                    </excludes>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>central-release</id>
            <properties>
                <maven.shade.skip>true</maven.shade.skip>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>3.3.0</version>
                        <executions>
                            <execution>
                                <id>attach-central-javadocs</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>attach-artifact</goal>
                                </goals>
                                <configuration>
                                    <artifacts>
                                        <artifact>
                                            <file>${project.build.directory}/${project.build.finalName}-javadoc.jar</file>
                                            <type>jar</type>
                                            <classifier>javadoc</classifier>
                                        </artifact>
                                    </artifacts>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.2.8</version>
                        <executions>
                            <execution>
                                <id>sign-release-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <bestPractices>true</bestPractices>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>0.12.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                            <autoPublish>true</autoPublish>
                            <waitUntil>published</waitUntil>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>skip-tests</id>
            <properties>
                <maven.test.skip>true</maven.test.skip>
            </properties>
        </profile>
        <!--
          分配量基准。这些类名为 *Benchmark、以 main() 运行，surefire 不会拾取，
          因此默认 mvn test 完全不受影响。按需显式执行：
            mvn -Pperf test-compile exec:exec@viewer-benchmark exec:exec@attack-benchmark
          之所以独立出来：每次调用的绝对分配字节数取决于 JIT 内联与逃逸分析、JDK 版本与 CPU 架构，
          把它当作 CI 门禁会让无关改动随机变红。功能行为由普通测试断言。
        -->
        <profile>
            <id>perf</id>
            <properties>
                <!-- 只跑 @Tag("perf") 的分配测量，默认 test 排除它们 -->
                <test.groups>perf</test.groups>
                <test.excludedGroups></test.excludedGroups>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>3.1.0</version>
                        <executions>
                            <execution>
                                <id>viewer-benchmark</id>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>${java.home}/bin/java</executable>
                                    <classpathScope>test</classpathScope>
                                    <arguments>
                                        <argument>-XX:-DoEscapeAnalysis</argument>
                                        <argument>-Xms256m</argument>
                                        <argument>-Xmx512m</argument>
                                        <argument>-cp</argument>
                                        <classpath/>
                                        <argument>cn.nukkit.entity.EntityViewerSnapshotBenchmark</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>attack-benchmark</id>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>${java.home}/bin/java</executable>
                                    <classpathScope>test</classpathScope>
                                    <arguments>
                                        <argument>-XX:-DoEscapeAnalysis</argument>
                                        <argument>-Xms256m</argument>
                                        <argument>-Xmx512m</argument>
                                        <argument>-cp</argument>
                                        <classpath/>
                                        <argument>cn.nukkit.entity.mob.EntityZombieAttackBenchmark</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <!--
          真实交叉编解码覆盖率：先跑测试（写 target/packet-coverage.txt），再运行报告。
          用法: mvn -Pcoverage test exec:exec@packet-coverage
          报告退出码非 0 表示没有实际执行记录，或有测试声明覆盖但从未执行。
        -->
        <profile>
            <id>coverage</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>3.1.0</version>
                        <executions>
                            <execution>
                                <id>packet-coverage</id>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>${java.home}/bin/java</executable>
                                    <classpathScope>test</classpathScope>
                                    <arguments>
                                        <argument>-cp</argument>
                                        <classpath/>
                                        <argument>cn.nukkit.network.protocol.regression.PacketCoverageReport</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
