<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <!-- Parent: Spring Boot starter parent -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.5.9</version>
        <relativePath/>
    </parent>

    <packaging>pom</packaging>
    <groupId>cn.cordys</groupId>
    <artifactId>cordys-crm</artifactId>
    <version>${revision}</version>
    <name>cordys-crm</name>

    <properties>
        <!-- Project meta -->
        <revision>main</revision>
        <java.version>21</java.version>

        <!-- Library versions -->
        <shiro.version>2.0.6</shiro.version>
        <fastexcel.version>1.3.0</fastexcel.version>
        <pagehelper.version>6.1.1</pagehelper.version>
        <quartz-starter.version>1.0.0</quartz-starter.version>
        <redisson-starter.version>3.52.0</redisson-starter.version>
        <mybatis-starter.version>3.0.5</mybatis-starter.version>
        <springdoc-openapi-ui.version>2.8.13</springdoc-openapi-ui.version>
        <flatten.version>1.6.0</flatten.version>
        <embedded.version>3.1.13</embedded.version>
        <mail.version>2.0.5</mail.version>

        <!-- Frontend build -->
        <frontend-maven-plugin.version>1.15.1</frontend-maven-plugin.version>
        <node.version>v22.16.0</node.version>
        <pnpm.version>10.4.1</pnpm.version>

        <!-- CI / tooling -->
        <skipAntRunForJenkins>false</skipAntRunForJenkins>
        <jacoco.version>0.8.12</jacoco.version>

        <!-- Sonar -->
        <sonar.organization>cordys-dev</sonar.organization>
        <sonar.host.url>https://sonarcloud.io</sonar.host.url>

        <!-- Commons & other versions -->
        <commons-collections4.version>4.5.0</commons-collections4.version>
        <commons-text.version>1.15.0</commons-text.version>
        <commons-io.version>2.21.0</commons-io.version>
        <commons-lang3.version>3.20.0</commons-lang3.version>
        <commons-codec.version>1.20.0</commons-codec.version>
        <testcontainers.version>2.0.3</testcontainers.version>
        <persistence-api.version>3.2.0</persistence-api.version>
        <commons-compress.version>1.28.0</commons-compress.version>
        <jwt.version>3.12.1</jwt.version>
    </properties>

    <modules>
        <module>frontend</module>
        <module>backend</module>
    </modules>

    <build>
        <!-- Resources: 保留 .properties .xml .json .tpl .js 等在 src/main/java 下的资源 -->
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                    <include>**/*.json</include>
                    <include>**/*.tpl</include>
                    <include>**/*.js</include>
                </includes>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>

        <plugins>
            <!-- Flatten plugin: 用于生成简化的 POM -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>flatten-maven-plugin</artifactId>
                <version>${flatten.version}</version>
                <configuration>
                    <updatePomFile>true</updatePomFile>
                    <flattenMode>resolveCiFriendliesOnly</flattenMode>
                </configuration>
                <executions>
                    <execution>
                        <id>flatten</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>flatten</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>flatten.clean</id>
                        <phase>clean</phase>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- JaCoCo: 代码覆盖率 -->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.version}</version>
                <configuration>
                    <excludes>
                        <exclude>cn/cordys/crm/*/mapper/**</exclude>
                        <exclude>cn/cordys/crm/*/domain/**</exclude>
                        <exclude>cn/cordys/common/**</exclude>
                        <exclude>cn/cordys/config/**</exclude>
                        <exclude>cn/cordys/aspectj/**</exclude>
                        <exclude>cn/cordys/mybatis/**</exclude>
                        <exclude>cn/cordys/security/**</exclude>
                    </excludes>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Maven Compiler: 指定 Java 发行版本 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <executions>
                    <!-- 禁用默认绑定，显式声明编译阶段 -->
                    <execution>
                        <id>default-compile</id>
                        <phase>none</phase>
                    </execution>
                    <execution>
                        <id>default-testCompile</id>
                        <phase>none</phase>
                    </execution>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>testCompile</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <release>${java.version}</release>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <!-- 发布仓库 -->
    <distributionManagement>
        <repository>
            <id>cordys-public</id>
            <url>https://repository.fit2cloud.com/repository/cordys/</url>
        </repository>
    </distributionManagement>

    <!-- 依赖仓库 -->
    <repositories>
        <repository>
            <id>central</id>
            <url>https://repo.maven.apache.org/maven2</url>
        </repository>
        <repository>
            <id>cordys-public</id>
            <url>https://repository.fit2cloud.com/repository/cordys/</url>
        </repository>
    </repositories>

    <!-- 插件仓库 -->
    <pluginRepositories>
        <pluginRepository>
            <id>central</id>
            <url>https://repo.maven.apache.org/maven2</url>
        </pluginRepository>
        <pluginRepository>
            <id>cordys-public</id>
            <url>https://repository.fit2cloud.com/repository/cordys/</url>
        </pluginRepository>
    </pluginRepositories>
</project>