<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         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>com.github.yujiaao</groupId>
        <artifactId>c-tools-parent</artifactId>
        <version>1.17.1.3</version>
    </parent>

    <artifactId>c-dbtools</artifactId>
    <name>Database ORM tools</name>

    <properties>
        <!-- 默认 h2 + 跳过 probe：避免每次 test-compile 起 JVM 连 MySQL（本地无库时极慢）。需要探测时用：-Dconnection.pool.profile=auto -->
        <connection.pool.profile>h2</connection.pool.profile>
        <connection.pool.probe.skip>true</connection.pool.probe.skip>
        <!-- 默认跳过 JaCoCo：本地单测不必每次插桩/写报告，显著加快。CI 传 -Djacoco.skip=false -->
        <jacoco.skip>true</jacoco.skip>
    </properties>
    <description>a fast small database connection pool and a active record flavor mini framework</description>
    <licenses>

        <license>
            <name>Apache License, Version 2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>
    <developers>
        <developer>
            <id>yujiaao</id>
            <name>Wanxiang Xing</name> <!-- 必选：开发者姓名 -->
            <email>yujiaao@msn.com</email>
            <roles>
                <role>Developer</role> <!-- 可选：角色描述 -->
            </roles>
        </developer>
    </developers>
    <build>
        <resources>
            <resource>
                <directory>src/test/resources</directory>
                <excludes>
                    <exclude>**/*.xml</exclude>
                    <exclude>**/*.xsd</exclude>
                    <exclude>**/*.dtd</exclude>
                    <exclude>**/*.sql</exclude>
                    <exclude>**/*.properties</exclude>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <includes>
                    <include>**/*.xml</include>
                    <include>**/*.properties</include>
                    <include>**/*.sql</include>
                </includes>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
                <configuration>
                    <useSystemClassLoader>false</useSystemClassLoader>
                    <!-- 父 POM 为 -Xmx4g，单测 fork 过大、启动慢；本模块覆盖为较小堆（仍保留 @{argLine} 供可选 jacoco） -->
                    <argLine>@{argLine} -server -ea -Xmx1024m</argLine>
                    <!-- 原先 20s/30s 过短：并行 + ConnectionManagerTest 等（MySQL 连接重试、多方法累计）
                         会在用例跑完前触发强杀，报 "There was a timeout or other error in the fork"。 -->
                    <parallelTestsTimeoutForcedInSeconds>600</parallelTestsTimeoutForcedInSeconds>
                    <forkedProcessTimeoutInSeconds>600</forkedProcessTimeoutInSeconds>
                    <!-- 并行多类会共抢同一 H2 mem:test / 静态池，易假死；单模块测试串行更快结束 -->
                    <parallel>none</parallel>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.8</version>
                <configuration>
                    <skip>${jacoco.skip}</skip>
                    <includes>com/bixuebihui/**</includes>
                    <includes>io/shardingjdbc/**</includes>
                </configuration>
                <executions>
                    <!-- 仅保留一次 prepare-agent；曾重复绑定 pre-test 导致双重插桩，单测极慢 -->
                    <execution>
                        <id>default-prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-check</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <rule implementation="org.jacoco.maven.RuleConfiguration">
                                    <element>BUNDLE</element>
                                    <limits>
                                        <limit implementation="org.jacoco.report.check.Limit">
                                            <counter>COMPLEXITY</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>0.60</minimum>
                                        </limit>
                                    </limits>
                                </rule>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <id>select-connection-pool-xml</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <skip>${connection.pool.probe.skip}</skip>
                            <mainClass>com.bixuebihui.testsupport.ConnectionPoolConfigProbe</mainClass>
                            <classpathScope>test</classpathScope>
                            <arguments>
                                <argument>${project.build.testOutputDirectory}</argument>
                                <argument>${connection.pool.profile}</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

    <profiles>
        <profile>
            <id>connection-pool-probe-auto</id>
            <activation>
                <property>
                    <name>connection.pool.profile</name>
                    <value>auto</value>
                </property>
            </activation>
            <properties>
                <connection.pool.probe.skip>false</connection.pool.probe.skip>
            </properties>
        </profile>
        <profile>
            <id>connection-pool-probe-mysql</id>
            <activation>
                <property>
                    <name>connection.pool.profile</name>
                    <value>mysql</value>
                </property>
            </activation>
            <properties>
                <connection.pool.probe.skip>false</connection.pool.probe.skip>
            </properties>
        </profile>
    </profiles>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>3.3.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.22.2</version>
                <configuration>
                    <outputDirectory>${basedir}/target/surefire-reports</outputDirectory>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jdepend-maven-plugin</artifactId>
                <version>2.1</version>
            </plugin>
            <plugin>
                <groupId>com.github.spotbugs</groupId>
                <artifactId>spotbugs-maven-plugin</artifactId>
                <version>4.8.6.0</version>
            </plugin>

        </plugins>
    </reporting>
    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
            <exclusions>
                <!-- 与 log4j-slf4j2-impl 同时存在时，Log4j2 API -> SLF4J -> Log4j2 会形成栈溢出 -->
                <exclusion>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-to-slf4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-text</artifactId>
        </dependency>

        <!-- supported and tested connection pool, can works with any or none -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-dbcp2</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Alibaba Druid -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.2.15</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.ibm.db2.jcc</groupId>
            <artifactId>db2jcc</artifactId>
            <version>db2jcc4</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.hibernate.validator</groupId>
            <artifactId>hibernate-validator</artifactId>
        </dependency>

        <dependency>
            <groupId>jakarta.validation</groupId>
            <artifactId>jakarta.validation-api</artifactId>
        </dependency>


        <dependency>
            <groupId>jakarta.el</groupId>
            <artifactId>jakarta.el-api</artifactId>
            <version>5.0.1</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.apache.derby/derby -->
        <dependency>
            <groupId>org.apache.derby</groupId>

            <artifactId>derby</artifactId>
<!--            <version>10.17.1.0</version> --> <!-- java 17 & higher -->
            <version>10.16.1.1</version>
            <!-- java 9 & higher -->
<!--            <version>10.14.2.0</version> &lt;!&ndash; java 8 & higher&ndash;&gt;-->
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.9.4</version>
            <exclusions>
                <exclusion>
                    <artifactId>commons-collections</artifactId>
                    <groupId>commons-collections</groupId>
                </exclusion>
            </exclusions>
        </dependency>


        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- LRUMap -->
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2.2</version>
        </dependency>

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>32.0.1-jre</version>
        </dependency>

        <!-- this can be removed, for web test only -->
        <dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>jakarta.servlet-api</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.easymock</groupId>
            <artifactId>easymock</artifactId>
            <version>5.1.0</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>2.2.220</version>
            <scope>test</scope>
        </dependency>


        <!-- API, java.xml.bind module for java 9 & up-->
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
            <version>4.0.0</version>
            <scope>provided</scope>
        </dependency>

        <!-- Runtime, com.sun.xml.bind module -->
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
            <version>4.0.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.17.0</version>
        </dependency>


        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>

        <!-- 不与 log4j-slf4j2-impl 同时引入 slf4j-simple，否则 SLF4J 会优先选用 SimpleServiceProvider，MDC 行为与 Log4j2 测试配置不一致 -->

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.19.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.19.0</version>
            <scope>test</scope>
        </dependency>
        <!-- SLF4J 2.x 必须使用 log4j-slf4j2-impl；log4j-slf4j-impl 仅适用于 SLF4J 1.7，会导致 MDC 等 API 不生效 -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j2-impl</artifactId>
            <version>2.19.0</version>
            <scope>test</scope>
        </dependency>
        <dependency> <!-- 引入log4j2依赖 -->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j2</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-slf4j-impl</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.github.yujiaao</groupId>
            <artifactId>common-utils</artifactId>
            <version>1.17.1.3</version>
            <scope>compile</scope>
        </dependency>


        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
            <version>${junitVersion}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junitVersion}</version>
            <scope>test</scope>
        </dependency>

        <!-- Parameterized Tests -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <version>${junitVersion}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <version>${hamcrest.version}</version>
            <scope>test</scope>
        </dependency>


        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-runner</artifactId>
            <scope>test</scope>
        </dependency>


        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-suite-engine</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>jakarta.el</artifactId>
            <version>5.0.0-M1</version>
        </dependency>

        <dependency>
            <groupId>org.glassfish.expressly</groupId>
            <artifactId>expressly</artifactId>
            <version>5.0.0</version>
        </dependency>

        <dependency>
            <groupId>net.sf.supercsv</groupId>
            <artifactId>super-csv</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.github.yujiaao</groupId>
                <artifactId>c-tools-bom</artifactId>
                <version>${project.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

</project>
