<?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-root</artifactId>
        <version>0.12.0</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>exeris-kernel-parent</artifactId>
    <packaging>pom</packaging>

    <name>Exeris Kernel - Parent</name>
    <description>
        Main Parent POM for Kernel modules.
        Imports the BOM and enforces strict Code Quality gates (Checkstyle, PMD).
    </description>
    <url>https://github.com/exeris-systems/exeris-kernel</url>

    <properties>
        <checkstyle.config.location>checkstyle.xml</checkstyle.config.location>
        <exec.maven.plugin.version>3.6.4</exec.maven.plugin.version>

        <!-- Benchmark parameters — all overridable on CLI with -D -->
        <benchmark.includes>.*</benchmark.includes>
        <benchmark.forks>3</benchmark.forks>
        <benchmark.warmup>5</benchmark.warmup>
        <benchmark.iterations>10</benchmark.iterations>
        <benchmark.warmuptime>2s</benchmark.warmuptime>
        <benchmark.iterationstime>2s</benchmark.iterationstime>
        <benchmark.jvm.gc>-XX:+UseZGC</benchmark.jvm.gc>
        <benchmark.jvmArgs></benchmark.jvmArgs>
        <benchmark.output>${project.build.directory}/jmh-results.json</benchmark.output>
        <!-- Default: benchmarks are skipped. Modules that contain @Benchmark classes
             must override this to false in their own pom.xml <properties>. -->
        <benchmark.skip>true</benchmark.skip>
        <!-- Default: empty — overridden by the os-windows / os-linux / os-macos profiles below. -->
        <native.lib.dir/>
        <jmh.version>1.37</jmh.version>
    </properties>

    <!-- OS-specific profiles resolve native.lib.dir for the current host; executable benchmark profiles remain defined in owning module POMs. -->
    <profiles>
        <profile>
            <id>os-windows</id>
            <activation>
                <os><family>windows</family></os>
            </activation>
            <properties>
                <native.lib.dir>${project.basedir}/../native-libs/windows-x86_64</native.lib.dir>
            </properties>
        </profile>
        <profile>
            <id>os-linux</id>
            <activation>
                <os><name>Linux</name></os>
            </activation>
            <properties>
                <native.lib.dir>${project.basedir}/../native-libs/linux-x86_64</native.lib.dir>
            </properties>
        </profile>
        <profile>
            <id>os-macos</id>
            <activation>
                <os><family>mac</family></os>
            </activation>
            <properties>
                <native.lib.dir>${project.basedir}/../native-libs/macos-aarch64</native.lib.dir>
            </properties>
        </profile>
    </profiles>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>eu.exeris</groupId>
                <artifactId>exeris-kernel-bom</artifactId>
                <version>${project.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>${exec.maven.plugin.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>3.28.0</version>
                <dependencies>
                    <dependency>
                        <groupId>net.sourceforge.pmd</groupId>
                        <artifactId>pmd-core</artifactId>
                        <version>7.28.0</version>
                    </dependency>
                    <dependency>
                        <groupId>net.sourceforge.pmd</groupId>
                        <artifactId>pmd-java</artifactId>
                        <version>7.28.0</version>
                    </dependency>
                    <dependency>
                        <groupId>eu.exeris</groupId>
                        <artifactId>exeris-kernel-build-config</artifactId>
                        <version>${project.version}</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <rulesets>
                        <ruleset>pmd-ruleset.xml</ruleset>
                    </rulesets>
                    <targetJdk>26</targetJdk>
                    <failOnViolation>true</failOnViolation>
                    <printFailingErrors>true</printFailingErrors>
                </configuration>
                <executions>
                    <execution>
                        <id>verify-complexity</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>3.6.0</version>
                <dependencies>
                    <dependency>
                        <groupId>eu.exeris</groupId>
                        <artifactId>exeris-kernel-build-config</artifactId>
                        <version>${project.version}</version>
                    </dependency>
                    <!-- Checkstyle 13.x is required for record pattern support in instanceof (java:S6878 / Java 21+).
                         Overrides the locally cached 9.3 which pre-dates that feature.
                         Source: https://mvnrepository.com/artifact/com.puppycrawl.tools/checkstyle -->
                    <dependency>
                        <groupId>com.puppycrawl.tools</groupId>
                        <artifactId>checkstyle</artifactId>
                        <version>13.11.0</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <!--
                        A property, not a literal. `checkstyle.config.location` is the plugin's
                        documented user property, but an explicit <configLocation> in the pom
                        overrides it silently: `-Dcheckstyle.config.location=/nonexistent.xml`
                        does not even fail. That is how the shared javadoc-gate came to run this
                        ruleset instead of its own, and report clean.
                    -->
                    <configLocation>${checkstyle.config.location}</configLocation>
                    <consoleOutput>true</consoleOutput>
                    <failsOnError>true</failsOnError>
                </configuration>
                <executions>
                    <execution>
                        <id>validate-architecture</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>4.6</version>
                <dependencies>
                    <dependency>
                        <groupId>eu.exeris</groupId>
                        <artifactId>exeris-kernel-build-config</artifactId>
                        <version>${project.version}</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <licenseSets>
                        <licenseSet>
                            <header>license-header.txt</header>
                            <includes>
                                <include>src/**/*.java</include>
                            </includes>
                        </licenseSet>
                    </licenseSets>
                    <mapping>
                        <java>SLASHSTAR_STYLE</java>
                    </mapping>
                </configuration>
                <executions>
                    <execution>
                        <id>check-licenses</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>