<?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>cn.lihongjie</groupId>
    <artifactId>fast-image-java</artifactId>
    <version>1.1.8</version>
    <packaging>jar</packaging>

    <name>Fast Image Java</name>
    <description>High-performance JPEG compression library with JNI support, featuring comprehensive benchmarking
        suite
    </description>
    <url>https://github.com/lihongjie0209/fast-image-java</url>
    <inceptionYear>2025</inceptionYear>

    <licenses>
        <license>
            <name>MIT License</name>
            <url>https://opensource.org/licenses/MIT</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <developers>
        <developer>
            <id>lihongjie0209</id>
            <name>Li Hongjie</name>
            <email>lihongjie0209@example.com</email>
            <url>https://github.com/lihongjie0209</url>
            <roles>
                <role>architect</role>
                <role>developer</role>
            </roles>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git://github.com/lihongjie0209/fast-image-java.git</connection>
        <developerConnection>scm:git:ssh://git@github.com:lihongjie0209/fast-image-java.git</developerConnection>
        <url>https://github.com/lihongjie0209/fast-image-java</url>
        <tag>HEAD</tag>
    </scm>

    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/lihongjie0209/fast-image-java/issues</url>
    </issueManagement>

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <!-- Plugin versions -->
        <maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
        <maven-surefire-plugin.version>3.0.0</maven-surefire-plugin.version>
        <maven-source-plugin.version>3.2.1</maven-source-plugin.version>
        <maven-javadoc-plugin.version>3.4.1</maven-javadoc-plugin.version>
        <maven-gpg-plugin.version>3.0.1</maven-gpg-plugin.version>
        <central-publishing-maven-plugin.version>0.4.0</central-publishing-maven-plugin.version>

        <!-- JMH version -->
        <jmh.version>0.5.2</jmh.version>

        <!-- SonarCloud -->
        <sonar.organization>lihongjie0209</sonar.organization>
        <sonar.host.url>https://sonarcloud.io</sonar.host.url>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>

        <!-- JMH for performance benchmarking -->
        <!-- https://mvnrepository.com/artifact/org.openjdk.jmh/jmh-core -->
        <dependency>
            <groupId>org.openjdk.jmh</groupId>
            <artifactId>jmh-core</artifactId>
            <version>1.37</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.openjdk.jmh/jmh-generator-annprocess -->
        <dependency>
            <groupId>org.openjdk.jmh</groupId>
            <artifactId>jmh-generator-annprocess</artifactId>
            <version>1.37</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <testSourceDirectory>src/test/java</testSourceDirectory>
        <plugins>
            <!-- Build Helper Plugin - Add additional test source directories -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>3.4.0</version>
                <executions>
                    <execution>
                        <id>add-test-source</id>
                        <phase>generate-test-sources</phase>
                        <goals>
                            <goal>add-test-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>src/test/manual/java</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- Maven编译插件 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>

            <!-- Maven测试插件 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>
                <configuration>
                    <includes>
                        <!-- Only run unit tests by default -->
                        <include>**/unit/**/*Test.java</include>
                        <include>**/unit/**/*Tests.java</include>
                    </includes>
                    <excludes>
                        <!-- Exclude manual analysis and debugging tests -->
                        <exclude>**/manual/**/*.java</exclude>
                        <!-- Exclude performance tests from normal CI runs -->
                        <exclude>**/performance/**/*.java</exclude>
                        <!-- Exclude old test files that don't follow unit test pattern -->
                        <exclude>**/QuickBenchmark.java</exclude>
                        <exclude>**/ImageCompressionBenchmark.java</exclude>
                        <exclude>**/RotationExample.java</exclude>
                        <!-- Exclude legacy test files in root image package -->
                        <exclude>**/CrossPlatformTest.java</exclude>
                        <exclude>**/FastImageUtilsTest.java</exclude>
                        <exclude>**/RotationTest.java</exclude>
                    </excludes>
                    <systemPropertyVariables>
                        <java.awt.headless>true</java.awt.headless>
                    </systemPropertyVariables>
                    <!-- Tests should fail if native library is not available -->
                    <testFailureIgnore>false</testFailureIgnore>
                    <!-- Capture test output -->
                    <redirectTestOutputToFile>false</redirectTestOutputToFile>
                </configuration>
                <executions>
                    <!-- Separate execution for performance tests -->
                    <execution>
                        <id>performance-tests</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/performance/**/*Test.java</include>
                                <include>**/performance/**/*Tests.java</include>
                                <include>**/performance/**/*Benchmark.java</include>
                            </includes>
                            <excludes>
                                <exclude>**/unit/**/*.java</exclude>
                            </excludes>
                            <!-- Performance tests can be more tolerant of failures -->
                            <testFailureIgnore>true</testFailureIgnore>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- JMH Benchmark Plugin -->

            <!-- 源码插件 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>${maven-source-plugin.version}</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Javadoc插件 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>${maven-javadoc-plugin.version}</version>
                <configuration>
                    <source>8</source>
                    <detectJavaApiLink>false</detectJavaApiLink>
                    <doclint>none</doclint>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- SonarCloud扫描 -->
            <plugin>
                <groupId>org.sonarsource.scanner.maven</groupId>
                <artifactId>sonar-maven-plugin</artifactId>
                <version>3.9.1.2184</version>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- Unit tests profile (default) -->
        <profile>
            <id>unit-tests</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <includes>
                                <include>**/unit/**/*Test.java</include>
                                <include>**/unit/**/*Tests.java</include>
                            </includes>
                            <excludes>
                                <exclude>**/manual/**/*.java</exclude>
                                <exclude>**/performance/**/*.java</exclude>
                            </excludes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Performance tests profile -->
        <profile>
            <id>performance-tests</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <includes>
                                <include>**/performance/**/*Test.java</include>
                                <include>**/performance/**/*Tests.java</include>
                                <include>**/performance/**/*Benchmark.java</include>
                            </includes>
                            <excludes>
                                <exclude>**/unit/**/*.java</exclude>
                                <exclude>**/manual/**/*.java</exclude>
                            </excludes>
                            <!-- Performance tests can be more tolerant -->
                            <testFailureIgnore>true</testFailureIgnore>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Manual analysis and debugging tests profile -->
        <profile>
            <id>manual-tests</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <includes>
                                <include>**/manual/**/*Test.java</include>
                                <include>**/manual/**/*Tests.java</include>
                                <include>**/manual/**/*Analysis*.java</include>
                            </includes>
                            <excludes>
                                <exclude>**/unit/**/*.java</exclude>
                                <exclude>**/performance/**/*.java</exclude>
                            </excludes>
                            <!-- Manual tests are for analysis, failures are expected -->
                            <testFailureIgnore>true</testFailureIgnore>
                            <!-- Show detailed output for analysis -->
                            <redirectTestOutputToFile>false</redirectTestOutputToFile>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Performance测试配置 -->
        <profile>
            <id>benchmark</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${maven-surefire-plugin.version}</version>
                        <configuration>
                            <includes>
                                <include>**/QuickBenchmark.java</include>
                            </includes>
                            <systemPropertyVariables>
                                <java.awt.headless>true</java.awt.headless>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- 发布配置 -->
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <!-- GPG签名插件 -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${maven-gpg-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <!-- Use pinentry-mode loopback for CI/CD -->
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Central Publishing插件 -->
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>${central-publishing-maven-plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                            <tokenAuth>true</tokenAuth>
                            <autoPublish>true</autoPublish>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Performance testing profile -->
    </profiles>

    <distributionManagement>
        <!-- Maven Central -->
        <repository>
            <id>central</id>
            <url>https://central.sonatype.com/api/v1/publisher</url>
        </repository>
    </distributionManagement>

</project>