<?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.lingniu.ingest</groupId>
    <artifactId>lingniu-vehicle-ingest</artifactId>
    <version>0.1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <name>lingniu-vehicle-ingest</name>
    <description>
        羚牛车辆数据接入平台 v2。
        模块化原子能力 + 协议解耦 + 业务/实时解耦 + 生产链路只支持 Kafka。
        Java 25 + Spring Boot 3.5.3 + Netty 4.2.9.Final + Disruptor + Virtual Threads。
    </description>

    <modules>
        <module>modules/core/ingest-api</module>
        <module>modules/core/ingest-facts</module>
        <module>modules/core/ingest-codec-common</module>
        <module>modules/core/ingest-core</module>
        <module>modules/core/session-core</module>
        <module>modules/core/vehicle-identity</module>
        <module>modules/core/observability</module>
        <module>modules/sinks/sink-kafka</module>
        <module>modules/sinks/sink-archive</module>
        <module>modules/sinks/tdengine-history-store</module>
        <module>modules/services/event-history-service</module>
        <module>modules/services/vehicle-stat-service</module>
        <module>modules/protocols/protocol-gb32960</module>
        <module>modules/protocols/protocol-jt808</module>
        <module>modules/inbound/inbound-mqtt</module>
        <module>modules/apps/gb32960-ingest-app</module>
        <module>modules/apps/jt808-ingest-app</module>
        <module>modules/apps/yutong-mqtt-app</module>
        <module>modules/apps/vehicle-history-app</module>
        <module>modules/apps/vehicle-analytics-app</module>
    </modules>

    <profiles>
        <profile>
            <id>optional-command-gateway</id>
            <modules>
                <module>modules/protocols/protocol-jt1078</module>
                <module>modules/apps/command-gateway</module>
            </modules>
            <dependencyManagement>
                <dependencies>
                    <dependency>
                        <groupId>com.lingniu.ingest</groupId>
                        <artifactId>protocol-jt1078</artifactId>
                        <version>${project.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>com.lingniu.ingest</groupId>
                        <artifactId>command-gateway</artifactId>
                        <version>${project.version}</version>
                    </dependency>
                </dependencies>
            </dependencyManagement>
        </profile>
        <profile>
            <id>optional-attachments</id>
            <modules>
                <module>modules/protocols/protocol-jsatl12</module>
            </modules>
            <dependencyManagement>
                <dependencies>
                    <dependency>
                        <groupId>com.lingniu.ingest</groupId>
                        <artifactId>protocol-jsatl12</artifactId>
                        <version>${project.version}</version>
                    </dependency>
                </dependencies>
            </dependencyManagement>
        </profile>
        <profile>
            <id>optional-latest-state</id>
            <modules>
                <module>modules/services/vehicle-state-service</module>
            </modules>
            <dependencyManagement>
                <dependencies>
                    <dependency>
                        <groupId>com.lingniu.ingest</groupId>
                        <artifactId>vehicle-state-service</artifactId>
                        <version>${project.version}</version>
                    </dependency>
                </dependencies>
            </dependencyManagement>
        </profile>
        <profile>
            <id>legacy-xinda</id>
            <modules>
                <module>modules/inbound/inbound-xinda-push</module>
                <module>modules/apps/xinda-push-app</module>
            </modules>
            <!--
              羚牛私仓：托管 legacy Xinda 依赖 org.lingniu:gps-push-client:1.0。
              访问凭证配置在 ~/.m2/settings.xml 的 <server><id>lingniu-nexus</id></server> 中，
              pom 不保存明文密码。默认生产 reactor 不需要访问该私仓。
            -->
            <repositories>
                <repository>
                    <id>lingniu-nexus</id>
                    <name>Lingniu Private Maven Repository</name>
                    <url>https://nexus.lnh2e.com/repository/maven-public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
            <dependencyManagement>
                <dependencies>
                    <dependency>
                        <groupId>com.lingniu.ingest</groupId>
                        <artifactId>inbound-xinda-push</artifactId>
                        <version>${project.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>com.lingniu.ingest</groupId>
                        <artifactId>xinda-push-app</artifactId>
                        <version>${project.version}</version>
                    </dependency>
                </dependencies>
            </dependencyManagement>
        </profile>
    </profiles>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>25</java.version>
        <maven.compiler.source>25</maven.compiler.source>
        <maven.compiler.target>25</maven.compiler.target>
        <maven.compiler.release>25</maven.compiler.release>

        <spring-boot.version>3.5.3</spring-boot.version>
        <spring-cloud-alibaba.version>2025.0.0.0</spring-cloud-alibaba.version>
        <netty.version>4.2.9.Final</netty.version>
        <disruptor.version>4.0.0</disruptor.version>
        <protobuf.version>4.28.3</protobuf.version>
        <kafka.version>3.8.1</kafka.version>
        <caffeine.version>3.1.8</caffeine.version>
        <resilience4j.version>2.2.0</resilience4j.version>
        <micrometer.version>1.13.6</micrometer.version>
        <paho-mqtt.version>1.2.5</paho-mqtt.version>
        <taos-jdbcdriver.version>3.8.4</taos-jdbcdriver.version>
        <springdoc-openapi.version>2.8.17</springdoc-openapi.version>
        <junit.version>5.11.3</junit.version>
        <assertj.version>3.26.3</assertj.version>
        <mockito.version>5.14.2</mockito.version>
    </properties>

    <!--
      所有版本管理集中在父 pom 的 dependencyManagement。
      子模块继承父 pom 即可直接使用，无需单独 import BOM，避免循环引用。
    -->
    <dependencyManagement>
        <dependencies>
            <!-- 外部 BOM —— Maven dependencyManagement 是先到先得，
                 netty-bom 必须放在 spring-boot-dependencies 之前才能覆盖
                 后者带的旧版 netty-all/netty-common（否则会被锁回 4.1.x）。 -->
            <dependency>
                <groupId>io.netty</groupId>
                <artifactId>netty-bom</artifactId>
                <version>${netty.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>${spring-cloud-alibaba.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>io.github.resilience4j</groupId>
                <artifactId>resilience4j-bom</artifactId>
                <version>${resilience4j.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>io.micrometer</groupId>
                <artifactId>micrometer-bom</artifactId>
                <version>${micrometer.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.junit</groupId>
                <artifactId>junit-bom</artifactId>
                <version>${junit.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <!-- 内部模块 -->
            <dependency>
                <groupId>com.lingniu.ingest</groupId>
                <artifactId>ingest-api</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.lingniu.ingest</groupId>
                <artifactId>ingest-facts</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.lingniu.ingest</groupId>
                <artifactId>ingest-core</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.lingniu.ingest</groupId>
                <artifactId>ingest-codec-common</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.lingniu.ingest</groupId>
                <artifactId>session-core</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.lingniu.ingest</groupId>
                <artifactId>vehicle-identity</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.lingniu.ingest</groupId>
                <artifactId>observability</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.lingniu.ingest</groupId>
                <artifactId>sink-kafka</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.lingniu.ingest</groupId>
                <artifactId>sink-archive</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.lingniu.ingest</groupId>
                <artifactId>tdengine-history-store</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.lingniu.ingest</groupId>
                <artifactId>event-history-service</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.lingniu.ingest</groupId>
                <artifactId>vehicle-stat-service</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.lingniu.ingest</groupId>
                <artifactId>protocol-gb32960</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.lingniu.ingest</groupId>
                <artifactId>protocol-jt808</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.lingniu.ingest</groupId>
                <artifactId>inbound-mqtt</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.lingniu.ingest</groupId>
                <artifactId>gb32960-ingest-app</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.lingniu.ingest</groupId>
                <artifactId>jt808-ingest-app</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.lingniu.ingest</groupId>
                <artifactId>yutong-mqtt-app</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.lingniu.ingest</groupId>
                <artifactId>vehicle-history-app</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.lingniu.ingest</groupId>
                <artifactId>vehicle-analytics-app</artifactId>
                <version>${project.version}</version>
            </dependency>

            <!-- 第三方（非 BOM 管理） -->
            <dependency>
                <groupId>com.lmax</groupId>
                <artifactId>disruptor</artifactId>
                <version>${disruptor.version}</version>
            </dependency>
            <dependency>
                <groupId>com.google.protobuf</groupId>
                <artifactId>protobuf-java</artifactId>
                <version>${protobuf.version}</version>
            </dependency>
            <dependency>
                <groupId>com.google.protobuf</groupId>
                <artifactId>protobuf-java-util</artifactId>
                <version>${protobuf.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.kafka</groupId>
                <artifactId>kafka-clients</artifactId>
                <version>${kafka.version}</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.paho</groupId>
                <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
                <version>${paho-mqtt.version}</version>
            </dependency>
            <dependency>
                <groupId>com.taosdata.jdbc</groupId>
                <artifactId>taos-jdbcdriver</artifactId>
                <version>${taos-jdbcdriver.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>commons-logging</groupId>
                        <artifactId>commons-logging</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.springdoc</groupId>
                <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
                <version>${springdoc-openapi.version}</version>
            </dependency>
            <dependency>
                <groupId>com.github.ben-manes.caffeine</groupId>
                <artifactId>caffeine</artifactId>
                <version>${caffeine.version}</version>
            </dependency>
            <dependency>
                <groupId>org.assertj</groupId>
                <artifactId>assertj-core</artifactId>
                <version>${assertj.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-core</artifactId>
                <version>${mockito.version}</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.13.0</version>
                    <configuration>
                        <release>${java.version}</release>
                        <parameters>true</parameters>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.5.2</version>
                </plugin>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>${spring-boot.version}</version>
                    <configuration>
                        <jvmArguments>--sun-misc-unsafe-memory-access=allow</jvmArguments>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>repackage</goal>
                                <goal>build-info</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>
