<?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.4</version>
    </parent>

    <artifactId>opencode-base-image</artifactId>
    <name>OpenCode Base Image</name>
    <description>Image processing utilities - resize, crop, rotate, watermark, compress, format conversion for JDK 25+. Includes core image data types (Raster, PixelFormat) merged from opencode-base-image-core in V1.0.4.</description>

    <!--
        V1.0.4 BREAKING CHANGE | V1.0.4 不兼容变更:

        (1) The optional dependency com.twelvemonkeys.imageio:imageio-webp has
        been removed. WebP support now ships via opencode-base-image-codec
        (native libwebp through FFM), so no extra classpath entry is required.
        Downstream users who still need twelvemonkeys for non-WebP reasons
        must declare it explicitly in their own POM.

        (2) The standalone module opencode-base-image-core has been merged
        into this module. Source packages cloud.opencode.base.image.core and
        cloud.opencode.base.image.core.exception are preserved verbatim, so
        downstream import statements require no changes. Downstream consumers
        should remove the opencode-base-image-core dependency and the
        `requires cloud.opencode.base.image.core` line from their
        module-info.java.

        (1) V1.0.4 移除可选依赖 com.twelvemonkeys.imageio:imageio-webp。
        WebP 支持改由 opencode-base-image-codec（通过 FFM 调用原生 libwebp）提供，
        无需额外 classpath。仍因其它原因需要 twelvemonkeys 的下游用户须自行声明。

        (2) V1.0.4 将独立模块 opencode-base-image-core 合并入本模块。
        源包 cloud.opencode.base.image.core 与
        cloud.opencode.base.image.core.exception 完整保留，
        下游 import 语句无需任何修改。下游使用方应从其 pom 中移除
        opencode-base-image-core 依赖，并从 module-info.java 中移除
        `requires cloud.opencode.base.image.core` 一行。
    -->

    <properties>
        <!-- 仅 -Pbenchmark profile 使用 / Only used by -Pbenchmark profile -->
        <exec-maven-plugin.version>3.4.1</exec-maven-plugin.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>cloud.opencode.base</groupId>
            <artifactId>opencode-base-core</artifactId>
        </dependency>

        <!--
            图像编解码模块（PNG/JPEG/WebP/BMP/GIF + Raster.fromXxx 工厂方法所需的 DecodedXxx 类型）
            Image codec module (PNG/JPEG/WebP/BMP/GIF + DecodedXxx types required by Raster.fromXxx factories)
            V1.0.4: 改为本模块的直接依赖（合并前为通过 image-core 的传递依赖）/
            V1.0.4: now a direct dependency (was transitive via image-core before the merge)
        -->
        <dependency>
            <groupId>cloud.opencode.base</groupId>
            <artifactId>opencode-base-image-codec</artifactId>
        </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>

        <!--
            JMH benchmark (test scope only). See -Pbenchmark profile.
            JMH 基准测试（仅 test scope）。详见 -Pbenchmark profile。
        -->
        <dependency>
            <groupId>org.openjdk.jmh</groupId>
            <artifactId>jmh-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.openjdk.jmh</groupId>
            <artifactId>jmh-generator-annprocess</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!--
                Configure the JMH annotation processor for test sources only.
                Generates META-INF/BenchmarkList consumed by JMH's runner.

                仅为 test 源配置 JMH 注解处理器，生成 JMH 运行时所读的
                META-INF/BenchmarkList。
             -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-testCompile</id>
                        <configuration>
                            <annotationProcessorPaths>
                                <path>
                                    <groupId>org.openjdk.jmh</groupId>
                                    <artifactId>jmh-generator-annprocess</artifactId>
                                    <version>${jmh.version}</version>
                                </path>
                            </annotationProcessorPaths>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!--
            JMH benchmark profile. Activate with `-Pbenchmark`.
            JMH 基准测试 profile，使用 `-Pbenchmark` 启用。
         -->
        <profile>
            <id>benchmark</id>
            <build>
                <plugins>
                    <!--
                        Use exec:exec so JMH's fork() spawns a real subprocess
                        with the complete test classpath.
                        使用 exec:exec 让 JMH 的 fork() 能以完整 test classpath
                        启动子进程。
                     -->
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>${exec-maven-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>jmh</id>
                                <phase>integration-test</phase>
                                <goals><goal>exec</goal></goals>
                                <configuration>
                                    <executable>java</executable>
                                    <classpathScope>test</classpathScope>
                                    <arguments>
                                        <argument>--enable-native-access=ALL-UNNAMED</argument>
                                        <argument>-classpath</argument>
                                        <classpath/>
                                        <argument>org.openjdk.jmh.Main</argument>
                                        <argument>.*Benchmark</argument>
                                        <argument>-rf</argument>
                                        <argument>json</argument>
                                        <argument>-rff</argument>
                                        <argument>${project.build.directory}/jmh-result.json</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
