<?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>io.github.lunasaw</groupId>
    <artifactId>sip-proxy</artifactId>
    <version>1.8.2</version>
    <packaging>pom</packaging>
    <modules>
        <module>sip-common</module>
        <module>sip-gb28181</module>
        <module>sip-gateway</module>
        <module>sip-test</module>
    </modules>
    <name>sip-proxy</name>
    <description>轻量级SIP框架封装</description>
    <url>https://github.com/lunasaw/gb28181-proxy</url>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <spring-boot.version>3.3.1</spring-boot.version>
        <luna-common.version>2.6.2</luna-common.version>
        <github.username>lunasaw</github.username>
        <app.profiles>${project.name}</app.profiles>
        <sip.version>1.3.0-91</sip.version>
        <dom4j.version>2.1.4</dom4j.version>
        <sip-proxy-common.version>1.8.2</sip-proxy-common.version>
        <gb28181-proxy.version>1.8.2</gb28181-proxy.version>
        <skywalking.version>9.1.0</skywalking.version>
        <guava.version>32.1.3-jre</guava.version>
        <caffeine.version>3.1.8</caffeine.version>
        <micrometer.version>1.12.0</micrometer.version>
    </properties>

    <developers>
        <developer>
            <name>luna</name>
            <id>luna</id>
            <email>iszychen@gmail.com</email>
        </developer>
    </developers>
    <licenses>
        <license>
            <name>Apache 2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0</url>
        </license>
    </licenses>
    <scm>
        <url>https://github.com/lunasaw/gb28181-proxy</url>
        <connection>https://github.com/lunasaw/gb28181-proxy</connection>
        <developerConnection>https://github.com/lunasaw/gb28181-proxy.git</developerConnection>
    </scm>

    <dependencyManagement>
        <dependencies>
            <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>io.github.lunasaw</groupId>
                <artifactId>luna-common</artifactId>
                <version>${luna-common.version}</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/javax.sip/jain-sip-ri -->
            <dependency>
                <groupId>javax.sip</groupId>
                <artifactId>jain-sip-ri</artifactId>
                <version>${sip.version}</version>
            </dependency>

            <dependency>
                <groupId>org.dom4j</groupId>
                <artifactId>dom4j</artifactId>
                <version>${dom4j.version}</version>
            </dependency>

            <dependency>
                <groupId>io.github.lunasaw</groupId>
                <artifactId>sip-common</artifactId>
                <version>${sip-proxy-common.version}</version>
            </dependency>

            <dependency>
                <groupId>io.github.lunasaw</groupId>
                <artifactId>gb28181-common</artifactId>
                <version>${sip-proxy-common.version}</version>
            </dependency>

            <dependency>
                <groupId>io.github.lunasaw</groupId>
                <artifactId>gb28181-server</artifactId>
                <version>${sip-proxy-common.version}</version>
            </dependency>

            <dependency>
                <groupId>io.github.lunasaw</groupId>
                <artifactId>gb28181-client</artifactId>
                <version>${sip-proxy-common.version}</version>
            </dependency>

            <!-- sip-gateway 父聚合新增 3 个子模块（BOM 不在此处 import，避免循环） -->
            <dependency>
                <groupId>io.github.lunasaw</groupId>
                <artifactId>gateway-core</artifactId>
                <version>${gb28181-proxy.version}</version>
            </dependency>
            <dependency>
                <groupId>io.github.lunasaw</groupId>
                <artifactId>gateway-gb28181</artifactId>
                <version>${gb28181-proxy.version}</version>
            </dependency>
            <dependency>
                <groupId>io.github.lunasaw</groupId>
                <artifactId>sip-gateway-spring-boot-starter</artifactId>
                <version>${gb28181-proxy.version}</version>
            </dependency>

            <!-- Guava工具库 -->
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>${guava.version}</version>
            </dependency>

            <!-- Caffeine缓存 -->
            <dependency>
                <groupId>com.github.ben-manes.caffeine</groupId>
                <artifactId>caffeine</artifactId>
                <version>${caffeine.version}</version>
            </dependency>

            <!-- Micrometer监控 -->
            <dependency>
                <groupId>io.micrometer</groupId>
                <artifactId>micrometer-core</artifactId>
                <version>${micrometer.version}</version>
            </dependency>

            <dependency>
                <groupId>io.micrometer</groupId>
                <artifactId>micrometer-registry-prometheus</artifactId>
                <version>${micrometer.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>io.github.lunasaw</groupId>
            <artifactId>luna-common</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring-boot.version}</version>
            </plugin>
            <!--
                JaCoCo 覆盖率：prepare-agent 在 initialize 阶段 attach（0 开销），
                report 在 verify 阶段渲染 target/site/jacoco/index.html。
                每个子模块独立产报告；aggregate 跨模块汇总报告由 gb28181-test 单独配置。
            -->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.12</version>
                <executions>
                    <execution>
                        <id>jacoco-prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>jacoco-report</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!--
                Surefire HTML 报告：把已有 surefire-reports/*.xml 渲染为
                target/reports/surefire.html。绑到 verify 阶段自动产出。
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>3.2.5</version>
                <executions>
                    <execution>
                        <id>surefire-report</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>report-only</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!--
                    协议分层守门：mvn verify 阶段同时跑两条 grep 脚本：
                      1) check-sip-common-purity.sh  — sip-common 不得含 GB28181 关键字
                      2) check-business-no-base-parser.sh — gb28181-{client,server} 不得越级调 RFC 4566 base parser
                    详见 doc/SDP-PARSER-LAYERING-PLAN.md §4.4
                -->
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <id>check-sip-common-purity</id>
                        <phase>verify</phase>
                        <goals><goal>exec</goal></goals>
                        <configuration>
                            <executable>bash</executable>
                            <workingDirectory>${maven.multiModuleProjectDirectory}</workingDirectory>
                            <arguments>
                                <argument>${maven.multiModuleProjectDirectory}/scripts/check-sip-common-purity.sh</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>check-business-no-base-parser</id>
                        <phase>verify</phase>
                        <goals><goal>exec</goal></goals>
                        <configuration>
                            <executable>bash</executable>
                            <workingDirectory>${maven.multiModuleProjectDirectory}</workingDirectory>
                            <arguments>
                                <argument>${maven.multiModuleProjectDirectory}/scripts/check-business-no-base-parser.sh</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>check-gateway-core-purity</id>
                        <phase>verify</phase>
                        <goals><goal>exec</goal></goals>
                        <configuration>
                            <executable>bash</executable>
                            <workingDirectory>${maven.multiModuleProjectDirectory}</workingDirectory>
                            <arguments>
                                <argument>${maven.multiModuleProjectDirectory}/scripts/check-gateway-core-purity.sh</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
                <inherited>false</inherited>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>github_auth</id>
            <distributionManagement>
                <repository>
                    <id>github_auth</id>
                    <name>GitHub OWNER Apache Maven Packages</name>
                    <url>https://maven.pkg.github.com/lunasaw/gb28181-proxy</url>
                </repository>
                <snapshotRepository>
                    <id>github_auth</id>
                    <name>GitHub OWNER Apache Maven Packages</name>
                    <url>https://maven.pkg.github.com/lunasaw/gb28181-proxy</url>
                </snapshotRepository>
            </distributionManagement>
            <repositories>
                <repository>
                    <!-- id需要与上面的server对应的id匹配 -->
                    <id>github_auth</id>
                    <name>GitHub OWNER Apache Maven Packages</name>
                    <url>https://maven.pkg.github.com/lunasaw/gb28181-proxy</url>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <profile>
            <id>ossrh</id>
            <distributionManagement>
                <repository>
                    <id>ossrh</id>
                    <url>https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/</url>
                </repository>
                <snapshotRepository>
                    <id>ossrh</id>
                    <url>https://ossrh-staging-api.central.sonatype.com/content/repositories/snapshots</url>
                </snapshotRepository>
            </distributionManagement>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <!--
                        Maven 中央仓库发布插件（Sonatype Central Portal 官方，2025+ 推荐）。
                        替换老的 nexus-staging-maven-plugin：后者按模块逐个连 Sonatype 做 profile 检查，
                        多模块下需连 N 次，任一次 TLS 握手卡死即整体 hang（实测 1.7.0 之后发布全失败的根因）。
                        central-publishing 把全部模块产物打成 1 个 bundle 一次性上传，根治多连接问题。
                          - extensions=true：接管默认 deploy 行为
                          - publishingServerId=ossrh：复用 settings.xml 中已有的 ossrh Portal token 凭证
                          - autoPublish=true：校验通过后自动发布（false 则需到 Portal 手动点 Publish）
                          - waitUntil=published：构建阻塞到真正发布完成，便于 CI 判定
                        测试/示例模块（sip-test / gb28181-test）通过 <skipPublishing>true</skipPublishing> 排除。
                    -->
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>0.10.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>ossrh</publishingServerId>
                            <autoPublish>true</autoPublish>
                            <waitUntil>published</waitUntil>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>3.0</version>
                        <configuration>
                            <source>17</source>
                            <target>17</target>
                            <encoding>utf-8</encoding>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.1.0</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <gpgArguments>
                                <arg>--pinentry-mode</arg>
                                <arg>loopback</arg>
                            </gpgArguments>
                        </configuration>
                    </plugin>
                    <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>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>2.9.1</version>
                        <configuration>
                            <!--<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>-->
                            <additionalparam>-Xdoclint:none</additionalparam>
                            <aggregate>true</aggregate>
                            <charset>UTF-8</charset><!-- utf-8读取文件 -->
                            <encoding>UTF-8</encoding><!-- utf-8进行编码代码 -->
                            <docencoding>UTF-8</docencoding><!-- utf-8进行编码文档 -->
                            <tags>
                                <tag>
                                    <name>date</name>
                                    <name>description</name>
                                </tag>
                            </tags>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>