<?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">
    <parent>
        <groupId>org.mock-server</groupId>
        <artifactId>mockserver</artifactId>
        <version>7.0.0</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>

    <artifactId>mockserver-core</artifactId>

    <name>MockServer Core</name>
    <description>Functionality used by all MockServer modules for matching and expectations</description>
    <url>https://www.mock-server.com</url>

    <properties>
        <module.name>org.mockserver.core</module.name>
    </properties>

    <dependencies>
        <!-- mockserver -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>mockserver-testing</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- disruptor -->
        <dependency>
            <groupId>com.lmax</groupId>
            <artifactId>disruptor</artifactId>
        </dependency>

        <!-- http -->
        <dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>jakarta.servlet-api</artifactId>
        </dependency>

        <!-- Netty -->
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-buffer</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-codec</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-codec-http</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-codec-http2</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-codec-socks</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-handler</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-handler-proxy</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-transport</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-tcnative-boringssl-static</artifactId>
        </dependency>
        <!-- Epoll API classes (pure Java, no native classifier) — needed at compile
             time for NettyTransport to reference EpollEventLoopGroup, EpollSocketChannel,
             EpollServerSocketChannel, and Epoll.isAvailable(). The native .so is only
             required at runtime on Linux (bundled in mockserver-netty). -->
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-transport-classes-epoll</artifactId>
        </dependency>

        <!-- protobuf (gRPC support) -->
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java-util</artifactId>
        </dependency>

        <!-- gzip HTTP deflater & inflater -->
        <dependency>
            <groupId>com.jcraft</groupId>
            <artifactId>jzlib</artifactId>
        </dependency>

        <!-- non-blocking UUID -->
        <dependency>
            <groupId>com.fasterxml.uuid</groupId>
            <artifactId>java-uuid-generator</artifactId>
        </dependency>

        <!-- SSL X509 -->
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk18on</artifactId>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcpkix-jdk18on</artifactId>
        </dependency>

        <!-- JWT -->
        <dependency>
            <groupId>com.nimbusds</groupId>
            <artifactId>nimbus-jose-jwt</artifactId>
        </dependency>

        <!-- templating -->
        <dependency>
            <groupId>org.apache.velocity</groupId>
            <artifactId>velocity-engine-scripting</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.velocity</groupId>
            <artifactId>velocity-engine-core</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.commons</groupId>
                    <artifactId>commons-lang3</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.velocity.tools</groupId>
            <artifactId>velocity-tools-generic</artifactId>
            <version>3.1</version>
        </dependency>
        <dependency>
            <groupId>com.samskivert</groupId>
            <artifactId>jmustache</artifactId>
        </dependency>
        <dependency>
            <groupId>net.datafaker</groupId>
            <artifactId>datafaker</artifactId>
        </dependency>

        <!-- WASM (chicory pure-Java interpreter) -->
        <dependency>
            <groupId>com.dylibso.chicory</groupId>
            <artifactId>runtime</artifactId>
            <optional>true</optional>
        </dependency>

        <!-- javascript (GraalVM polyglot) -->
        <dependency>
            <groupId>org.graalvm.polyglot</groupId>
            <artifactId>polyglot</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.graalvm.polyglot</groupId>
            <artifactId>js</artifactId>
            <type>pom</type>
            <optional>true</optional>
        </dependency>

        <!-- json (object serialisation) -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-annotations</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>net.javacrumbs.json-unit</groupId>
            <artifactId>json-unit-core</artifactId>
        </dependency>
        <dependency>
            <!-- json-unit's Configuration.withMatcher exposes org.hamcrest.Matcher; json-unit
                 declares only the hamcrest-core stub which has no classes since 3.0, so the
                 hamcrest classes must be pulled in explicitly for compile-time visibility. -->
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest</artifactId>
        </dependency>

        <!-- json validation -->
        <dependency>
            <groupId>com.networknt</groupId>
            <artifactId>json-schema-validator</artifactId>
        </dependency>
        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path</artifactId>
        </dependency>

        <!-- open api -->
        <dependency>
            <groupId>io.swagger.parser.v3</groupId>
            <artifactId>swagger-parser</artifactId>
        </dependency>
        <dependency>
            <!-- upgrade swagger-parser dependency fixing
                 https://security.snyk.io/vuln/SNYK-JAVA-ORGMOZILLA-1314295 -->
            <groupId>org.mozilla</groupId>
            <artifactId>rhino</artifactId>
        </dependency>

        <!-- xml -->
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.xmlunit</groupId>
            <artifactId>xmlunit-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.xmlunit</groupId>
            <artifactId>xmlunit-placeholders</artifactId>
        </dependency>

        <!-- commons & guava -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-text</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.commons</groupId>
                    <artifactId>commons-lang3</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>

        <!-- classpath scanning -->
        <dependency>
            <groupId>io.github.classgraph</groupId>
            <artifactId>classgraph</artifactId>
        </dependency>

        <!-- logging -->
        <dependency> <!-- will map to any underlying logging framework -->
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-jdk14</artifactId>
            <optional>true</optional> <!-- do not impose on project importing mock-server -->
        </dependency>

        <!-- prometheus -->
        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>prometheus-metrics-core</artifactId>
        </dependency>
        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>prometheus-metrics-exposition-formats</artifactId>
        </dependency>
        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>prometheus-metrics-model</artifactId>
        </dependency>

        <!-- opentelemetry (optional metrics export; off by default).
             OTLP HTTP/protobuf via the JDK HttpClient sender — okhttp sender excluded
             to avoid pulling okhttp + kotlin-stdlib into the shaded jar. -->
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-api</artifactId>
        </dependency>
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-sdk-common</artifactId>
        </dependency>
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-sdk-metrics</artifactId>
        </dependency>
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-sdk-trace</artifactId>
        </dependency>
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-exporter-otlp</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>io.opentelemetry</groupId>
                    <artifactId>opentelemetry-exporter-sender-okhttp</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-exporter-sender-jdk</artifactId>
        </dependency>
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-sdk-testing</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.skyscreamer</groupId>
            <artifactId>jsonassert</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!--
                Capture the abbreviated git commit hash at build time and expose it as the
                ${git.commit.id.abbrev} Maven property, which the templating-maven-plugin (inherited
                from the parent pom) substitutes into the generated Version class so it can be surfaced
                on the /mockserver/status endpoint and the Prometheus build_info metric. Runs in the
                initialize phase, before generate-sources where the Version class is filtered.
                failOnNoGitDirectory / failOnUnableToExtractRepoInfo are false so builds without git
                metadata (e.g. a source tarball) degrade to an empty hash instead of failing.
            -->
            <plugin>
                <groupId>io.github.git-commit-id</groupId>
                <artifactId>git-commit-id-maven-plugin</artifactId>
                <version>9.0.1</version>
                <executions>
                    <execution>
                        <id>resolve-git-commit-hash</id>
                        <goals>
                            <goal>revision</goal>
                        </goals>
                        <phase>initialize</phase>
                    </execution>
                </executions>
                <configuration>
                    <failOnNoGitDirectory>false</failOnNoGitDirectory>
                    <failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
                    <generateGitPropertiesFile>false</generateGitPropertiesFile>
                    <abbrevLength>8</abbrevLength>
                    <includeOnlyProperties>
                        <includeOnlyProperty>^git\.commit\.id\.abbrev$</includeOnlyProperty>
                    </includeOnlyProperties>
                    <!--
                        NOTE: inside a linked git worktree the resolved hash is that of the shared
                        repository HEAD, not the worktree's own HEAD. Single-working-tree clones
                        (Buildkite CI and the release pipeline, which is what ships) resolve correctly.
                    -->
                </configuration>
            </plugin>
            <!--
                Two-phase unit-test execution (see docs/operations/performance-tuning.md):
                  1. default-test     - parallel=classes (threadCount 4) for the bulk of the suite.
                  2. sequential-tests - parallel=none, ONLY the classes listed below, which mutate
                     JVM-global state that cannot be thread-isolated and so must not run concurrently:
                       - ConfigurationProperties system-property config (ConfigurationTest,
                         ProxyConfigurationTest, ExceptionHandlingTest, CustomJsonUnitMatcherLoaderTest)
                       - static Prometheus Metrics gauges (MockServerMatcherNotificationAndMetricsTest)
                       - globally-fixed time for assertions on timestamps produced on the event-log
                         disruptor thread (HttpStateTest, MockServerEventLogTest)
                The ConfigurationProperties/MockServerLogger <clinit> deadlock that previously made
                parallel=classes hang is fixed (ClassInitializationDeadlockTest); UUIDService/
                EpochService/TimeService global booleans are now thread-scoped so their former victims
                run safely in the parallel phase. ParallelStaticStateGuardTest fails the build if a
                class is excluded from the parallel phase without being added to the sequential phase.
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <parallel>classes</parallel>
                    <threadCount>4</threadCount>
                    <excludes>
                        <exclude>**/*IntegrationTest.java</exclude>
                        <exclude>**/ConfigurationTest.java</exclude>
                        <exclude>**/ProxyConfigurationTest.java</exclude>
                        <exclude>**/ExceptionHandlingTest.java</exclude>
                        <exclude>**/CustomJsonUnitMatcherLoaderTest.java</exclude>
                        <exclude>**/MockServerMatcherNotificationAndMetricsTest.java</exclude>
                        <exclude>**/MockServerEventLogTest.java</exclude>
                        <exclude>**/HttpStateTest.java</exclude>
                        <exclude>**/OtelMetricsExporterTest.java</exclude>
                        <exclude>**/TimeServiceTest.java</exclude>
                        <exclude>**/TimeToLiveTest.java</exclude>
                        <exclude>**/ExpectationTest.java</exclude>
                        <exclude>**/HttpActionHandlerChaosTest.java</exclude>
                        <exclude>**/HttpActionHandlerForwardChaosTest.java</exclude>
                        <exclude>**/ServiceChaosRegistryTest.java</exclude>
                        <exclude>**/TcpChaosRegistryTest.java</exclude>
                        <exclude>**/MetricsTest.java</exclude>
                        <exclude>**/MetricsHandlerTest.java</exclude>
                        <exclude>**/HttpRequestsPropertiesMatcherTest.java</exclude>
                        <exclude>**/HttpRequestPropertiesMatcherLogTest.java</exclude>
                        <exclude>**/GenAiSpansTest.java</exclude>
                        <exclude>**/RequestSpansTest.java</exclude>
                        <!-- Run sequentially: these render templates that evaluate several XPath
                             expressions, each bounded by xpathMatchingTimeoutMillis via the shared
                             MatchingTimeoutExecutor. Under heavy parallel CPU contention an eval can
                             miss its wall-clock timeout and fall back to "" (flaky). Running them
                             single-threaded removes the contention without weakening the prod timeout. -->
                        <exclude>**/MustacheTemplateEngineTest.java</exclude>
                        <exclude>**/VelocityTemplateEngineTest.java</exclude>
                    </excludes>
                </configuration>
                <executions>
                    <execution>
                        <id>sequential-tests</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <phase>test</phase>
                        <configuration>
                            <parallel>none</parallel>
                            <forkCount>1</forkCount>
                            <reuseForks>true</reuseForks>
                            <excludes combine.self="override">
                                <exclude>**/*IntegrationTest.java</exclude>
                            </excludes>
                            <includes combine.self="override">
                                <include>**/ConfigurationTest.java</include>
                                <include>**/ProxyConfigurationTest.java</include>
                                <include>**/ExceptionHandlingTest.java</include>
                                <include>**/CustomJsonUnitMatcherLoaderTest.java</include>
                                <include>**/MockServerMatcherNotificationAndMetricsTest.java</include>
                                <include>**/MockServerEventLogTest.java</include>
                                <include>**/HttpStateTest.java</include>
                                <include>**/OtelMetricsExporterTest.java</include>
                                <include>**/TimeServiceTest.java</include>
                                <include>**/TimeToLiveTest.java</include>
                                <include>**/ExpectationTest.java</include>
                                <include>**/HttpActionHandlerChaosTest.java</include>
                                <include>**/HttpActionHandlerForwardChaosTest.java</include>
                                <include>**/ServiceChaosRegistryTest.java</include>
                                <include>**/TcpChaosRegistryTest.java</include>
                                <include>**/MetricsTest.java</include>
                                <include>**/MetricsHandlerTest.java</include>
                                <include>**/HttpRequestsPropertiesMatcherTest.java</include>
                                <include>**/HttpRequestPropertiesMatcherLogTest.java</include>
                                <include>**/GenAiSpansTest.java</include>
                                <include>**/RequestSpansTest.java</include>
                                <!-- XPath-in-template tests: sequential to avoid flaky timeout under contention -->
                                <include>**/MustacheTemplateEngineTest.java</include>
                                <include>**/VelocityTemplateEngineTest.java</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- jacoco:check minimum set ~3 points below the measured unit-test floor of 0.6858 (M6 ratchet, 2026-05-28). Tighter threshold catches genuine coverage regressions without flaking on small natural variation.
                 BRANCH bundle minimum (0.40) ensures branch coverage doesn't regress. -->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>check</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <rule>
                                    <element>BUNDLE</element>
                                    <limits>
                                        <limit>
                                            <counter>LINE</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>0.65</minimum>
                                        </limit>
                                        <limit>
                                            <counter>BRANCH</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>0.40</minimum>
                                        </limit>
                                    </limits>
                                </rule>
                                <!-- NOTE: a per-CLASS LINE floor was tried but is not enforceable on this
                                     codebase — ~80 existing classes have <30% unit-line coverage (many 0%).
                                     Enforcing "new/changed code must be covered" needs a diff-coverage gate,
                                     not a JaCoCo per-class rule; tracked as a follow-up. BUNDLE LINE+BRANCH kept. -->
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- produce a test-jar so sibling modules (e.g. mockserver-blob-s3/gcs/azure)
                 can reuse the shared BlobStoreContract without duplicating it -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/state/contract/**</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
