<?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>eu.exeris</groupId>
        <artifactId>exeris-kernel-parent</artifactId>
        <version>0.12.0</version>
        <relativePath>../exeris-kernel-parent/pom.xml</relativePath>
    </parent>

    <artifactId>exeris-kernel-core</artifactId>

    <name>Exeris Kernel :: Core</name>
    <description>
        The "Brain": KernelBootstrap orchestrator, AbstractLoanedBuffer base class,
        WatermarkManager, ResourceArbiter. Depends only on exeris-kernel-spi.
    </description>
    <url>https://github.com/exeris-systems/exeris-kernel</url>

    <properties>
        <exeris.module.name>eu.exeris.kernel.core</exeris.module.name>
        <!--
            v0.8 Sprint 6 (Coverage C-P0-01): LINE coverage floor for the Core bundle.
            Current measurement: ~74% (deepest test coverage in the reactor — TCK
            backing + JFR event sites). Ratchet at 0.65 — regressions blocked.
        -->
        <jacoco.line.minimum>0.65</jacoco.line.minimum>
        <!-- BRANCH baseline 2026-06-10: 62.0% (1623/2618). Ratchet ~7 pp below. -->
        <jacoco.branch.minimum>0.55</jacoco.branch.minimum>
    </properties>

    <dependencies>
        <!-- SPI contracts — The Wall -->
        <dependency>
            <groupId>eu.exeris</groupId>
            <artifactId>exeris-kernel-spi</artifactId>
        </dependency>

        <!--
            JCTools — lock-free queues. Used in AsyncTelemetrySink (PERF-070):
            MpscArrayQueue replaces ArrayBlockingQueue so producers no longer
            contend on the ABQ lock under multi-VT emission load.
            Version managed by exeris-kernel-bom.
        -->
        <dependency>
            <groupId>org.jctools</groupId>
            <artifactId>jctools-core</artifactId>
        </dependency>

        <!-- TCK abstract test contracts — test scope only -->
        <dependency>
            <groupId>eu.exeris</groupId>
            <artifactId>exeris-kernel-tck</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- JMH — JVM Microbenchmark Harness (abstract benchmarks live in TCK test-jar) -->
        <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>
        <!-- Test framework -->
        <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>
        <!-- Test: certificate material for the OpenSSL integration tests, generated per run -->
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcpkix-jdk18on</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <!-- Filter only the version stamp; keep all other resources unfiltered (no binary corruption). -->
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>exeris-kernel.properties</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>exeris-kernel.properties</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.openjdk.jmh</groupId>
                            <artifactId>jmh-generator-annprocess</artifactId>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>3.2.5</version>
                <configuration>
                    <argLine>@{coverage.argLine} ${jvm.args} --add-opens java.base/sun.nio.ch=ALL-UNNAMED</argLine>
                    <includes>
                        <include>**/*IT.java</include>
                    </includes>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>benchmarks</id>
            <properties>
                <benchmark.skip>false</benchmark.skip>
                <benchmark.warmuptime>2s</benchmark.warmuptime>
                <benchmark.iterationstime>2s</benchmark.iterationstime>
                <benchmark.jvm.gc>-XX:+UseZGC</benchmark.jvm.gc>
                <benchmark.jvmArgs></benchmark.jvmArgs>
                <benchmark.jvmArgsAppend/>
                <excludedGroups/>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <!--
                            ADR-066: no plugin-level compilerArgs here. Plugin level applies to
                            default-compile too, so this profile handed the preview flag to MAIN
                            sources as well; the root POM's pluginManagement already puts it on
                            default-testCompile, which is the only place it belongs.

                            It was NOT producing preview-stamped main classes. Measured both ways:
                            307 main classes, 0 stamped. javac stamps minor_version 0xFFFF on
                            classes that actually USE a preview feature, not on everything compiled
                            under the flag, and main sources use none. What the plugin-level
                            placement did produce is a profile that silently disagreed with the
                            default build about what main sources may contain: the day a preview
                            feature lands in one, the normal build refuses it and the benchmark
                            build compiles it.
                        -->
                        <configuration>
                            <release>${maven.compiler.release}</release>
                            <annotationProcessorPaths>
                                <path>
                                    <groupId>org.openjdk.jmh</groupId>
                                    <artifactId>jmh-generator-annprocess</artifactId>
                                    <version>${jmh.version}</version>
                                </path>
                            </annotationProcessorPaths>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>run-benchmarks</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <skip>${benchmark.skip}</skip>
                                    <executable>java</executable>
                                    <classpathScope>test</classpathScope>
                                    <arguments>
                                        <argument>-XX:+UnlockExperimentalVMOptions</argument>
                                        <argument>${benchmark.jvm.gc}</argument>
                                        <argument>--enable-native-access=ALL-UNNAMED</argument>
                                        <argument>-Djava.library.path=${java.library.path}${path.separator}${native.lib.dir}</argument>
                                        <argument>--add-opens</argument>
                                        <argument>java.base/sun.nio.ch=ALL-UNNAMED</argument>
                                        <argument>-classpath</argument>
                                        <classpath/>
                                        <argument>org.openjdk.jmh.Main</argument>
                                        <argument>${benchmark.includes}</argument>
                                        <argument>-f</argument>
                                        <argument>${benchmark.forks}</argument>
                                        <argument>-wi</argument>
                                        <argument>${benchmark.warmup}</argument>
                                        <argument>-i</argument>
                                        <argument>${benchmark.iterations}</argument>
                                        <argument>-w</argument>
                                        <argument>${benchmark.warmuptime}</argument>
                                        <argument>-r</argument>
                                        <argument>${benchmark.iterationstime}</argument>
                                        <argument>-rf</argument>
                                        <argument>json</argument>
                                        <argument>-rff</argument>
                                        <argument>${benchmark.output}</argument>
                                        <argument>-jvmArgsAppend</argument>
                                        <argument>${benchmark.jvmArgsAppend}</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
