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

    <parent>
        <groupId>cloud.opencode.base</groupId>
        <artifactId>opencode-base-parent</artifactId>
        <version>1.0.5</version>
    </parent>

    <artifactId>opencode-base-flow</artifactId>
    <name>OpenCode Base Flow</name>
    <description>OpenCode Base Flow - Lightweight approval workflow engine with JSON DSL (JDK 25+)</description>

    <properties>
        <!-- japicmp 插件版本 / japicmp plugin version -->
        <japicmp-plugin.version>0.23.1</japicmp-plugin.version>
    </properties>

    <dependencies>
        <!-- ============ 必选依赖 / Required dependencies ============ -->
        <dependency>
            <groupId>cloud.opencode.base</groupId>
            <artifactId>opencode-base-core</artifactId>
        </dependency>
        <dependency>
            <groupId>cloud.opencode.base</groupId>
            <artifactId>opencode-base-json</artifactId>
        </dependency>
        <dependency>
            <groupId>cloud.opencode.base</groupId>
            <artifactId>opencode-base-id</artifactId>
        </dependency>
        <dependency>
            <groupId>cloud.opencode.base</groupId>
            <artifactId>opencode-base-event</artifactId>
        </dependency>

        <!-- ============ 可选依赖 / Optional dependencies ============ -->
        <dependency>
            <groupId>cloud.opencode.base</groupId>
            <artifactId>opencode-base-expression</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>cloud.opencode.base</groupId>
            <artifactId>opencode-base-i18n</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>cloud.opencode.base</groupId>
            <artifactId>opencode-base-observability</artifactId>
            <optional>true</optional>
        </dependency>

        <!-- ============ 测试依赖 / Test dependencies ============ -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- ============ S4 / M4 JDBC + 集成测试依赖（仅 test scope，不下传） ============ -->
        <!-- ============ S4 / M4 JDBC + integration-test dependencies (test scope, not transitive) ============ -->
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>2.3.232</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <version>9.1.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.7.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>mysql</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>postgresql</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- jacoco：恢复至 parent 默认阈值 0.80（Phase 6 已补齐 18+ 测试，
                 实际指令覆盖率达标）。详见 pmdoc/base-flow/测试报告.md。
                 jacoco threshold restored to parent default 0.80 after Phase 6 added
                 18+ tests targeting the previously low-coverage classes. See
                 pmdoc/base-flow/测试报告.md for the breakdown. -->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>check</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <rule>
                                    <element>BUNDLE</element>
                                    <limits>
                                        <limit>
                                            <counter>INSTRUCTION</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>0.80</minimum>
                                        </limit>
                                    </limits>
                                </rule>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- japicmp：API 兼容性检查（仅 opencode-base-flow 启用，避免对存量 42 个模块全量拦截）
                 首发 1.0.5，无基线；后续版本以 1.0.5 JAR 为 baseline。
                 japicmp: API compatibility check (enabled only for opencode-base-flow to avoid
                 blocking the existing 42 modules). First release is 1.0.5 with no baseline;
                 subsequent versions will baseline against the 1.0.5 JAR. -->
            <plugin>
                <groupId>com.github.siom79.japicmp</groupId>
                <artifactId>japicmp-maven-plugin</artifactId>
                <version>${japicmp-plugin.version}</version>
                <configuration>
                    <!-- 首发 1.0.5：oldVersion 自比新 JAR（"self-baseline"），
                         产出"无 API 变化"报告并通过；自 1.0.6 起，把 oldVersion
                         的 path 改为已发布 1.0.5 jar 即可启用真实回归检测。
                         First release 1.0.5: use the new JAR as its own baseline
                         (self-baseline trick) so the comparison emits an empty
                         diff and passes. From 1.0.6 on, swap oldVersion.file.path
                         to the published 1.0.5 jar to enable real regression
                         detection. -->
                    <oldVersion>
                        <file>
                            <path>${project.build.directory}/${project.build.finalName}.jar</path>
                        </file>
                    </oldVersion>
                    <newVersion>
                        <file>
                            <path>${project.build.directory}/${project.build.finalName}.jar</path>
                        </file>
                    </newVersion>
                    <parameter>
                        <onlyModified>true</onlyModified>
                        <breakBuildOnModifications>false</breakBuildOnModifications>
                        <breakBuildOnBinaryIncompatibleModifications>false</breakBuildOnBinaryIncompatibleModifications>
                        <skipPomModules>true</skipPomModules>
                    </parameter>
                    <skipMissingOldVersion>true</skipMissingOldVersion>
                    <failOnMissingClassFile>false</failOnMissingClassFile>
                </configuration>
                <executions>
                    <execution>
                        <id>japicmp-check</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>cmp</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
