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

    <name>MockServer &amp; Proxy Netty</name>
    <artifactId>mockserver-netty</artifactId>
    <url>https://www.mock-server.com</url>

    <properties>
        <module.name>org.mockserver.netty</module.name>
        <maven-invoker-parallel-threads>2</maven-invoker-parallel-threads>
    </properties>

    <dependencies>
        <!-- mockserver -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>mockserver-client-java</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>mockserver-core</artifactId>
        </dependency>
        <!-- AsyncAPI messaging module — optional feature; wired into the
             running server so the PUT/GET /mockserver/asyncapi control-plane
             endpoints are functional. The module self-registers via
             AsyncApiControlPlaneImpl.registerIfAvailable() at startup. -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>mockserver-async</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>mockserver-integration-testing</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>mockserver-testing</artifactId>
            <scope>test</scope>
        </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-common</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-handler</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-transport</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-codec-dns</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 SoOriginalDstResolver to reference EpollSocketChannel/Epoll.
             The native .so is only required at runtime on Linux. -->
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-transport-classes-epoll</artifactId>
        </dependency>
        <!-- Epoll native .so — bundles the Linux-specific JNI library that activates
             io.netty.channel.epoll.Epoll.isAvailable(). Runtime-only; on non-Linux
             platforms these JARs are inert (no native to load). Both x86_64 and aarch64
             are included so Docker images work on both AMD64 and ARM64 hosts. -->
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-transport-native-epoll</artifactId>
            <classifier>linux-x86_64</classifier>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-transport-native-epoll</artifactId>
            <classifier>linux-aarch_64</classifier>
            <scope>runtime</scope>
        </dependency>
        <!-- JNA — used by SoOriginalDstResolver for getsockopt(SO_ORIGINAL_DST)
             on Linux. On non-Linux platforms the JNA code path is never invoked;
             the resolver reports unsupported and falls through to conntrack. -->
        <dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna</artifactId>
        </dependency>

        <!-- HTTP/3 (QUIC) — graduated from incubator into Netty 4.2; the native
             QUIC library is bundled transitively by netty-codec-http3 for
             supported platforms. CI/CD must run on a platform where the native
             is available (linux-x86_64, osx-x86_64, osx-aarch_64) or the
             HTTP/3 feature will be unavailable. -->
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-codec-http3</artifactId>
        </dependency>

        <!-- commons & guava -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</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>

        <!-- 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.hamcrest</groupId>
            <artifactId>hamcrest</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- make jar executable -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.5.0</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>org.mockserver.cli.Main</mainClass>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <!-- generate single runnable jar (assembly:single) -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <skipAssembly>${skipAssembly}</skipAssembly>
                    <tarLongFileMode>posix</tarLongFileMode>
                    <archive>
                        <manifest>
                            <mainClass>org.mockserver.cli.Main</mainClass>
                        </manifest>
                    </archive>
                    <descriptors>
                        <descriptor>src/main/assembly/jar-with-dependencies/jar-with-dependencies.xml</descriptor>
                        <descriptor>src/main/assembly/brew-tar/brew-tar.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- shaded dependency maven integration tests -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-invoker-plugin</artifactId>
                <version>3.10.1</version>
                <configuration>
                    <skipInvocation>${skipTests}</skipInvocation>
                    <debug>false</debug>
                    <!-- only stream the invoked child Maven build log on
                         failure (invoker 3.3+) — passing builds stay quiet so
                         the CI log is not flooded with per-invoker child output. -->
                    <streamLogs>false</streamLogs>
                    <streamLogsOnFailures>true</streamLogsOnFailures>
                    <showErrors>true</showErrors>
                    <showVersion>true</showVersion>
                    <disableReports>true</disableReports>
                    <parallelThreads>${maven-invoker-parallel-threads}</parallelThreads>
                    <projectsDirectory>${basedir}/src/integration-tests/</projectsDirectory>
                    <cloneProjectsTo>${project.build.directory}/integration-tests/</cloneProjectsTo>
                    <reportsDirectory>${project.build.directory}</reportsDirectory>
                    <cloneClean>true</cloneClean>
                    <ignoreFailures>false</ignoreFailures>
                    <addTestClassPath>true</addTestClassPath>
                    <properties>
                        <property>
                            <name>mockserver.version</name>
                            <value>${project.version}</value>
                        </property>
                    </properties>
                    <environmentVariables>
                        <mockserver.logLevel>DEBUG</mockserver.logLevel>
                    </environmentVariables>
                    <filterProperties>
                        <mockserver.version>${project.version}</mockserver.version>
                    </filterProperties>
                    <settingsFile>src/integration-tests/settings.xml</settingsFile>
                    <!--<mavenOpts>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005</mavenOpts>-->
                    <pomIncludes>
                        <pomInclude>maven-**/pom.xml</pomInclude>
                    </pomIncludes>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <goals>
                            <goal>install</goal>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- jacoco:check minimum set ~4 points below the measured unit-test floor of 0.5931 (M6 ratchet, 2026-05-28). Tighter threshold catches genuine coverage regressions without flaking on small natural variation.
                 BRANCH bundle minimum (0.35) 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.55</minimum>
                                        </limit>
                                        <limit>
                                            <counter>BRANCH</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>0.35</minimum>
                                        </limit>
                                    </limits>
                                </rule>
                                <!-- per-CLASS LINE floor removed: not enforceable here (many existing
                                     handlers have <30% unit-line coverage). BUNDLE LINE+BRANCH retained. -->
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>build-ui</id>
            <activation>
                <file>
                    <exists>../../mockserver-ui/package.json</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <version>2.0.0</version>
                        <configuration>
                            <workingDirectory>${project.basedir}/../../mockserver-ui</workingDirectory>
                            <installDirectory>${project.build.directory}/frontend</installDirectory>
                        </configuration>
                        <executions>
                            <execution>
                                <id>install-node-and-npm</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>install-node-and-npm</goal>
                                </goals>
                                <configuration>
                                    <nodeVersion>v22.14.0</nodeVersion>
                                </configuration>
                            </execution>
                            <execution>
                                <id>npm-ci</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>npm</goal>
                                </goals>
                                <configuration>
                                    <arguments>ci</arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>npm-build</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>npm</goal>
                                </goals>
                                <configuration>
                                    <arguments>run build</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <version>3.5.0</version>
                        <executions>
                            <execution>
                                <id>copy-ui-build</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <overwrite>true</overwrite>
                                    <resources>
                                        <resource>
                                            <directory>${project.basedir}/../../mockserver-ui/build</directory>
                                            <filtering>false</filtering>
                                        </resource>
                                    </resources>
                                    <outputDirectory>${project.build.outputDirectory}/org/mockserver/dashboard</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
