<?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>com.njcn</groupId>
    <artifactId>cn-rdms</artifactId>
    <version>${revision}</version>
    <packaging>pom</packaging>
    <modules>
        <module>rdms-system</module>
        <module>rdms-project</module>
        <module>rdms-framework</module>
        <module>rdms-gateway</module>
    </modules>
    <name>${project.artifactId}</name>
    <description>灿能研发管理系统</description>
    <properties>
        <revision>V-0.5</revision>
        <!-- Maven 相关 -->
        <java.version>17</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <maven-surefire-plugin.version>3.5.3</maven-surefire-plugin.version>
        <maven-compiler-plugin.version>3.14.0</maven-compiler-plugin.version>
        <flatten-maven-plugin.version>1.7.2</flatten-maven-plugin.version>
        <!-- maven-surefire-plugin 暂时无法通过 bom 的依赖读取（兼容老版本 IDEA 2024 及以前版本） -->
        <lombok.version>1.18.42</lombok.version>
        <spring.boot.version>3.5.9</spring.boot.version>
        <mapstruct.version>1.6.3</mapstruct.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <swagger.version>2.2.38</swagger.version>
        <maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>

        <!-- Nacos 连接信息（注册中心 + 配置中心公共项）。
             各模块 application.yaml 用 @nacos.xxx@ 占位符引用，打包时由资源过滤注入；
             单点维护，运行期仍可由环境变量（如 SPRING_CLOUD_NACOS_SERVER_ADDR）覆盖。 -->
        <nacos.server-addr>192.168.1.103:18848</nacos.server-addr>
        <nacos.namespace>1924bcfb-4eab-4c58-9003-4a37d5fc2949</nacos.namespace>
        <nacos.group>DEFAULT_GROUP</nacos.group>
        <nacos.username></nacos.username>
        <nacos.password></nacos.password>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.njcn</groupId>
                <artifactId>njcn-dependencies-bom-jdk17</artifactId>
                <version>1.0.0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <!-- 项目内部模块版本管理 -->
            <dependency>
                <groupId>com.njcn</groupId>
                <artifactId>rdms-common</artifactId>
                <version>${revision}</version>
            </dependency>

            <dependency>
                <groupId>com.njcn</groupId>
                <artifactId>rdms-spring-boot-starter-biz-ip</artifactId>
                <version>${revision}</version>
            </dependency>

            <dependency>
                <groupId>com.njcn</groupId>
                <artifactId>rdms-spring-boot-starter-env</artifactId>
                <version>${revision}</version>
            </dependency>

            <dependency>
                <groupId>com.njcn</groupId>
                <artifactId>rdms-spring-boot-starter-excel</artifactId>
                <version>${revision}</version>
            </dependency>

            <dependency>
                <groupId>com.njcn</groupId>
                <artifactId>rdms-spring-boot-starter-mq</artifactId>
                <version>${revision}</version>
            </dependency>

            <dependency>
                <groupId>com.njcn</groupId>
                <artifactId>rdms-spring-boot-starter-mybatis</artifactId>
                <version>${revision}</version>
            </dependency>

            <dependency>
                <groupId>com.njcn</groupId>
                <artifactId>rdms-spring-boot-starter-protection</artifactId>
                <version>${revision}</version>
            </dependency>

            <dependency>
                <groupId>com.njcn</groupId>
                <artifactId>rdms-spring-boot-starter-redis</artifactId>
                <version>${revision}</version>
            </dependency>

            <dependency>
                <groupId>com.njcn</groupId>
                <artifactId>rdms-spring-boot-starter-rpc</artifactId>
                <version>${revision}</version>
            </dependency>

            <dependency>
                <groupId>com.njcn</groupId>
                <artifactId>rdms-spring-boot-starter-security</artifactId>
                <version>${revision}</version>
            </dependency>

            <dependency>
                <groupId>com.njcn</groupId>
                <artifactId>rdms-spring-boot-starter-test</artifactId>
                <version>${revision}</version>
            </dependency>

            <dependency>
                <groupId>com.njcn</groupId>
                <artifactId>rdms-spring-boot-starter-web</artifactId>
                <version>${revision}</version>
            </dependency>

            <dependency>
                <groupId>com.njcn</groupId>
                <artifactId>rdms-spring-boot-starter-websocket</artifactId>
                <version>${revision}</version>
            </dependency>

            <!-- 热部署依赖-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-devtools</artifactId>
                <version>${spring.boot.version}</version>
                <scope>runtime</scope>
                <optional>true</optional>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <!-- 资源过滤：仅对 application*/bootstrap* 配置文件开启过滤（注入 @nacos.xxx@ 等 pom 属性），
             其余资源（验证码底图等二进制）一律不过滤，避免被破坏。 -->
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>application*.yml</include>
                    <include>application*.yaml</include>
                    <include>bootstrap*.yml</include>
                    <include>bootstrap*.yaml</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>application*.yml</exclude>
                    <exclude>application*.yaml</exclude>
                    <exclude>bootstrap*.yml</exclude>
                    <exclude>bootstrap*.yaml</exclude>
                </excludes>
            </resource>
        </resources>

        <pluginManagement>
            <plugins>
                <!-- maven-resources-plugin 插件，配置 @ 为唯一占位符分隔符，
                     关闭默认 ${} 分隔符，避免 Maven 误解析 Spring 自身的 ${...} 占位符。 -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>${maven-resources-plugin.version}</version>
                    <configuration>
                        <useDefaultDelimiters>false</useDefaultDelimiters>
                        <delimiters>
                            <delimiter>@</delimiter>
                        </delimiters>
                    </configuration>
                </plugin>
                <!-- maven-surefire-plugin 插件，用于运行单元测试。 -->
                <!-- 注意，需要使用 3.0.X+，因为要支持 Junit 5 版本 -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven-surefire-plugin.version}</version>
                </plugin>
                <!-- maven-compiler-plugin 插件，解决 Lombok + MapStruct 组合 -->
                <!-- https://stackoverflow.com/questions/33483697/re-run-spring-boot-configuration-annotation-processor-to-update-generated-metada -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven-compiler-plugin.version}</version>
                    <configuration>
                        <source>17</source>
                        <target>17</target>
                        <annotationProcessorPaths>
                            <path>
                                <groupId>org.springframework.boot</groupId>
                                <artifactId>spring-boot-configuration-processor</artifactId>
                                <version>${spring.boot.version}</version>
                            </path>
                            <path>
                                <groupId>org.projectlombok</groupId>
                                <artifactId>lombok</artifactId>
                                <version>${lombok.version}</version>
                            </path>
                            <path>
                                <!-- 确保 Lombok 生成的 getter/setter 方法能被 MapStruct 正确识别，
                                     避免出现 No property named “xxx" exists 的编译错误 -->
                                <groupId>org.projectlombok</groupId>
                                <artifactId>lombok-mapstruct-binding</artifactId>
                                <version>0.2.0</version>
                            </path>
                            <path>
                                <groupId>org.mapstruct</groupId>
                                <artifactId>mapstruct-processor</artifactId>
                                <version>${mapstruct.version}</version>
                            </path>
                        </annotationProcessorPaths>
                        <!-- 编译参数写在 arg 内，解决 Spring Boot 3.2 的 Parameter Name Discovery 问题 -->
                        <debug>false</debug>
                        <compilerArgs>
                            <arg>-parameters</arg>
                        </compilerArgs>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <!-- 统一 revision 版本 -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>flatten-maven-plugin</artifactId>
                <version>${flatten-maven-plugin.version}</version>
                <configuration>
                    <flattenMode>oss</flattenMode>
                    <updatePomFile>true</updatePomFile>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>flatten</goal>
                        </goals>
                        <id>flatten</id>
                        <phase>process-resources</phase>
                    </execution>
                    <execution>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                        <id>flatten.clean</id>
                        <phase>clean</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <!-- 使用 huawei / aliyun 的 Maven 源，提升下载速度 -->
    <repositories>
        <repository>
            <id>huaweicloud</id>
            <name>huawei</name>
            <url>https://mirrors.huaweicloud.com/repository/maven/</url>
        </repository>
        <repository>
            <id>aliyunmaven</id>
            <name>aliyun</name>
            <url>https://maven.aliyun.com/repository/public</url>
        </repository>

        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <releases>
                <enabled>false</enabled>
            </releases>
        </repository>
    </repositories>

</project>
