<?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
                             https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>4.1.2</version>
        <relativePath/>
    </parent>

    <groupId>com.netmoor.moorhaven</groupId>
    <artifactId>moorhaven-parent</artifactId>
    <version>0.3.1</version>
    <packaging>pom</packaging>

    <name>Moorhaven</name>
    <description>Self-hosted media server — modular monolith</description>

    <properties>
        <!-- Версия задаётся CI: -Drevision=X.Y.Z (тег) или X.Y+1.0-SNAPSHOT (main); руками не правится.
             flatten-maven-plugin подставляет её в публикуемые pom (ADR 0009 платформы netmoor). -->
        <revision>0.0.0-SNAPSHOT</revision>
        <java.version>25</java.version>
        <!-- Jib: образы собирает общий конвейер netmoor/ci-templates (jib:build в модулях с jib.skip=false).
             База — наш moorhaven-base (docker/base/Dockerfile: temurin-jre + ffmpeg + fpcalc + libjsig в
             LD_PRELOAD, non-root uid 1000), который платформа собирает отдельным workflow. -->
        <jib.skip>true</jib.skip>
        <!-- Версия базового образа (тег base-vX.Y.Z -> harbor.home.arpa/apps/moorhaven-base:X.Y.Z).
             Отдельное свойство, чтобы Renovate обновлял его по тегам образа в Harbor. -->
        <moorhaven.base.version>1.0.1</moorhaven.base.version>
        <jib.from.image>harbor.home.arpa/apps/moorhaven-base:${moorhaven.base.version}</jib.from.image>
        <!-- Offline geocoding data built by scripts/geodata/build_geodata.py and published by
             .gitea/workflows/geodata.yml (Gitea Packages). moorhaven-app downloads it at build time,
             verifies the sha256 and ships it in the jar; the server installs it into its data directory.
             To refresh: run the workflow with a new version, copy version + sha256 from its log. -->
        <moorhaven.geodata.version>2026.10.28</moorhaven.geodata.version>
        <moorhaven.geodata.sha256>fb8abad1c94cafe85d0524aa6cf6948b9ce07b98894319f4f816c275bc97c680</moorhaven.geodata.sha256>
        <moorhaven.geodata.url>https://gitea.netmoor.com/api/packages/netmoor/maven/com/netmoor/moorhaven/moorhaven-geodata/${moorhaven.geodata.version}/moorhaven-geodata-${moorhaven.geodata.version}.zip</moorhaven.geodata.url>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <!-- true — surefire пропускает тесты всех модулей, кроме moorhaven-app (там skip=false явно).
             Для Quality / cluster-verify: профиль cluster меняет только состав приложения, тесты
             остальных модулей уже прогнал CI на стандартной композиции. -->
        <skip.module.tests>false</skip.module.tests>

        <!-- Spring Modulith -->
        <spring-modulith.version>2.1.2</spring-modulith.version>

        <!-- Hazelcast -->
        <hazelcast.version>5.7.0</hazelcast.version>

        <!-- Mapping & Validation -->
        <mapstruct.version>1.6.3</mapstruct.version>
        <lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version>

        <!-- API Documentation -->
        <springdoc.version>3.2.0</springdoc.version>

        <!-- Security -->
        <nimbus-jose-jwt.version>10.10</nimbus-jose-jwt.version>
        <totp.version>1.7.1</totp.version>
        <web-push.version>5.1.2</web-push.version>
        <!-- CVE-2025-14813 (CRITICAL), CVE-2026-8763/-13506 (HIGH). Above smbj's own
             1.79 requirement, so RequireUpperBound still holds. -->
        <bouncycastle.version>1.86</bouncycastle.version>
        <!-- web-push declares 0.7.0 (CVE-2023-31582, CVE-2024-29371); not managed by the
             Spring Boot BOM, so pinned here and forced transitively below. -->
        <jose4j.version>0.9.7</jose4j.version>

        <!-- Database -->
        <postgresql.version>42.7.14</postgresql.version>
        <sqlite-jdbc.version>3.54.1.0</sqlite-jdbc.version>
        <!-- Aligned with the version Spring Boot 4.0.8 manages (avoids an
             enforcer upper-bound conflict from spring-boot-liquibase). -->
        <liquibase.version>5.0.4</liquibase.version>
        <!-- Boot 4.0.8 still manages 2.5, but liquibase-core 5.0.3 itself declares 2.6 directly:
             bump past it to keep RequireUpperBoundDeps happy. -->
        <snakeyaml.version>2.7</snakeyaml.version>

        <!-- Torrent engine: libtorrent4j (SWIG/JNI over libtorrent). Native code
             ships in per-platform jars, bundled into the fat jar (no separate download).
             Do not bump to 2.1.0-39 blindly: its linux native needs GLIBC_2.38
             (breaks Debian 12 = the CI image), and it does NOT fix the JVM SIGSEGV
             seen with an active torrent on Ubuntu 26.04/JDK 25 (2026-07-08, both
             -35 and -39 crash; the app-level crash-loop breaker contains it). -->
        <libtorrent4j.version>2.1.0-39</libtorrent4j.version>
        <!-- Pinned above bt-core's transitive 30.1-jre: older Guava calls
             sun.misc.Unsafe (JVM deprecation warning); 33.x uses VarHandle. -->
        <guava.version>33.7.2-jre</guava.version>

        <!-- Object storage: AWS SDK v2 (S3-compatible, used for MinIO/S3 backend). -->
        <awssdk.version>2.57.8</awssdk.version>

        <!-- Native network storage client (no OS mount): SMB via smbj, pure-Java
             (fits the jlink/jpackage standalone). -->
        <smbj.version>0.15.0</smbj.version>
        <!-- mDNS/DNS-SD advertising of the REST API on the LAN (ADR-010). -->
        <jmdns.version>3.6.5</jmdns.version>
        <!-- ArchUnit for ModularityTests/SecurityArchitectureTests; also pins the copy Modulith
             pulls in at runtime (see the convergence pin below). -->
        <archunit.version>1.5.1</archunit.version>

        <!-- DLNA/UPnP media server (jUPnP, maintained Cling fork). moorhaven-dlna
             brings its own JDK HttpServer/HttpClient StreamServer/StreamClient
             (see com.netmoor.moorhaven.dlna.transport), so jUPnP's built-in Jetty 9.4
             transport is never on the classpath (issue #66). -->
        <jupnp.version>3.0.5</jupnp.version>

        <!-- Photo-AI: ONNX Runtime (Java), bundles per-platform native libs.
             Runs CLIP ViT-B/32 image/text encoders on CPU in standalone. -->
        <onnxruntime.version>1.31.1</onnxruntime.version>

        <!-- Native payload per target platform (profiles native-*, see the profiles section).
             The defaults below are the 'native-all' build: every platform's natives, only
             debug symbols dropped. A native-<os>-<arch> profile overrides them so the fat jar
             carries just one platform. Consumed by moorhaven-torrent-client (libtorrent4j scopes)
             and by the repack modules moorhaven-onnxruntime-slim / moorhaven-sqlite-slim
             (dependency:unpack excludes, Ant patterns). -->
        <native.libtorrent4j.windows.scope>runtime</native.libtorrent4j.windows.scope>
        <native.libtorrent4j.linux.scope>runtime</native.libtorrent4j.linux.scope>
        <native.libtorrent4j.macos.scope>runtime</native.libtorrent4j.macos.scope>
        <!-- The slim modules share one GAV across profiles: only the native-all build may put them into
             ~/.m2 (a single-platform copy there would silently slim every later -pl build). -->
        <native.slim.install.skip>false</native.slim.install.skip>

        <!-- onnxruntime 1.20 ships five platforms in one jar (no classifiers), plus a 300 MB win-x64
             onnxruntime.pdb and macOS .dSYM bundles. Debug symbols are never wanted at runtime. -->
        <native.onnxruntime.base-excludes>META-INF/MANIFEST.MF,META-INF/maven/**,**/*.pdb,**/*.dSYM/**</native.onnxruntime.base-excludes>
        <native.onnxruntime.ex.linux-x64>ai/onnxruntime/native/linux-x64/**</native.onnxruntime.ex.linux-x64>
        <native.onnxruntime.ex.linux-aarch64>ai/onnxruntime/native/linux-aarch64/**</native.onnxruntime.ex.linux-aarch64>
        <native.onnxruntime.ex.osx-x64>ai/onnxruntime/native/osx-x64/**</native.onnxruntime.ex.osx-x64>
        <native.onnxruntime.ex.osx-aarch64>ai/onnxruntime/native/osx-aarch64/**</native.onnxruntime.ex.osx-aarch64>
        <native.onnxruntime.ex.win-x64>ai/onnxruntime/native/win-x64/**</native.onnxruntime.ex.win-x64>
        <native.onnxruntime.excludes>${native.onnxruntime.base-excludes}</native.onnxruntime.excludes>

        <!-- sqlite-jdbc: org/sqlite/native/<OS>/<arch>/. Only glibc Linux is kept in single-platform
             builds (the Docker images are Debian); Musl, Android and FreeBSD are dropped there. -->
        <native.sqlite.base-excludes>META-INF/MANIFEST.MF,META-INF/maven/**/pom.xml</native.sqlite.base-excludes>
        <native.sqlite.ex.foreign-os>org/sqlite/native/FreeBSD/**,org/sqlite/native/Linux-Android/**,org/sqlite/native/Linux-Musl/**</native.sqlite.ex.foreign-os>
        <native.sqlite.ex.windows>org/sqlite/native/Windows/**</native.sqlite.ex.windows>
        <native.sqlite.ex.windows-not-x64>org/sqlite/native/Windows/x86/**,org/sqlite/native/Windows/armv7/**,org/sqlite/native/Windows/aarch64/**</native.sqlite.ex.windows-not-x64>
        <native.sqlite.ex.mac>org/sqlite/native/Mac/**</native.sqlite.ex.mac>
        <native.sqlite.ex.mac-x64>org/sqlite/native/Mac/x86_64/**</native.sqlite.ex.mac-x64>
        <native.sqlite.ex.mac-arm64>org/sqlite/native/Mac/aarch64/**</native.sqlite.ex.mac-arm64>
        <native.sqlite.ex.linux>org/sqlite/native/Linux/**</native.sqlite.ex.linux>
        <native.sqlite.ex.linux-minor-arch>org/sqlite/native/Linux/x86/**,org/sqlite/native/Linux/armv7/**,org/sqlite/native/Linux/armv6/**,org/sqlite/native/Linux/arm/**,org/sqlite/native/Linux/ppc64/**,org/sqlite/native/Linux/riscv64/**</native.sqlite.ex.linux-minor-arch>
        <native.sqlite.ex.linux-x64>org/sqlite/native/Linux/x86_64/**</native.sqlite.ex.linux-x64>
        <native.sqlite.ex.linux-arm64>org/sqlite/native/Linux/aarch64/**</native.sqlite.ex.linux-arm64>
        <native.sqlite.excludes>${native.sqlite.base-excludes}</native.sqlite.excludes>

        <!-- Build plugins -->
        <checkstyle.version>13.11.0</checkstyle.version>
        <checkstyle-plugin.version>3.6.0</checkstyle-plugin.version>
        <enforcer-plugin.version>3.7.0</enforcer-plugin.version>
        <spotless-plugin.version>2.46.1</spotless-plugin.version>
        <palantir-format.version>2.71.0</palantir-format.version>

        <!-- Mutation testing (PIT). Opt-in via the 'mutation' profile; never runs in a
             normal build. JDK 25 needs a recent PIT: 1.25.6 bundled ASM 9.10 (reads
             class-file 69), 1.25.8 fixed the BigDecimal/BigInteger mutators for Java 25.
             1.30.0 continues the 1.25.x line (1.29.10 was a mislabelled tag). -->
        <pitest-maven.version>1.30.1</pitest-maven.version>
        <pitest-junit5.version>1.2.3</pitest-junit5.version>

        <!-- Code coverage (JaCoCo). Opt-in via the 'coverage' profile. 0.8.14+ officially
             supports Java 25 class files (major 69). -->
        <jacoco.version>0.8.16</jacoco.version>
        <!-- Minimum line coverage a module must meet under 'jacoco:check'. Ratchet: bump to
             0.90 in a module's own POM once its tests reach the target, so it can't regress.
             Modules that haven't been driven up yet inherit 0.00 and don't block the build. -->
        <jacoco.min>0.00</jacoco.min>
    </properties>

    <modules>
        <module>moorhaven-core</module>
        <module>moorhaven-hazelcast</module>
        <module>moorhaven-inprocess</module>
        <module>moorhaven-security</module>
        <module>moorhaven-backup</module>
        <module>moorhaven-web</module>
        <module>moorhaven-notification</module>
        <module>moorhaven-file-storage</module>
        <module>moorhaven-media-library</module>
        <module>moorhaven-onnxruntime-slim</module>
        <module>moorhaven-sqlite-slim</module>
        <module>moorhaven-photo-ai</module>
        <module>moorhaven-streaming</module>
        <module>moorhaven-cameras</module>
        <module>moorhaven-ai-hailo</module>
        <module>moorhaven-torrent-client</module>
        <module>moorhaven-ha-integration</module>
        <module>moorhaven-dlna</module>
        <module>moorhaven-plugin-host</module>
        <module>moorhaven-plugin-example</module>
        <module>moorhaven-app</module>
        <module>moorhaven-cli</module>
        <module>moorhaven-coverage</module>
    </modules>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.modulith</groupId>
                <artifactId>spring-modulith-bom</artifactId>
                <version>${spring-modulith.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>software.amazon.awssdk</groupId>
                <artifactId>bom</artifactId>
                <version>${awssdk.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>com.netmoor.moorhaven</groupId>
                <artifactId>moorhaven-core</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.netmoor.moorhaven</groupId>
                <artifactId>moorhaven-hazelcast</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.netmoor.moorhaven</groupId>
                <artifactId>moorhaven-inprocess</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.netmoor.moorhaven</groupId>
                <artifactId>moorhaven-security</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.netmoor.moorhaven</groupId>
                <artifactId>moorhaven-backup</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.netmoor.moorhaven</groupId>
                <artifactId>moorhaven-web</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.netmoor.moorhaven</groupId>
                <artifactId>moorhaven-notification</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.netmoor.moorhaven</groupId>
                <artifactId>moorhaven-file-storage</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.netmoor.moorhaven</groupId>
                <artifactId>moorhaven-media-library</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.netmoor.moorhaven</groupId>
                <artifactId>moorhaven-photo-ai</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.netmoor.moorhaven</groupId>
                <artifactId>moorhaven-streaming</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.netmoor.moorhaven</groupId>
                <artifactId>moorhaven-cameras</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.netmoor.moorhaven</groupId>
                <artifactId>moorhaven-ai-hailo</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.netmoor.moorhaven</groupId>
                <artifactId>moorhaven-torrent-client</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.netmoor.moorhaven</groupId>
                <artifactId>moorhaven-ha-integration</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.netmoor.moorhaven</groupId>
                <artifactId>moorhaven-dlna</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.netmoor.moorhaven</groupId>
                <artifactId>moorhaven-plugin-host</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.netmoor.moorhaven</groupId>
                <artifactId>moorhaven-app</artifactId>
                <version>${project.version}</version>
            </dependency>

            <!-- Third-party native-carrying jars, repacked per target platform (native-* profiles). -->
            <dependency>
                <groupId>com.netmoor.moorhaven</groupId>
                <artifactId>moorhaven-onnxruntime-slim</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.netmoor.moorhaven</groupId>
                <artifactId>moorhaven-sqlite-slim</artifactId>
                <version>${project.version}</version>
            </dependency>

            <!-- DLNA/UPnP (jUPnP) -->
            <dependency>
                <groupId>org.jupnp</groupId>
                <artifactId>org.jupnp</artifactId>
                <version>${jupnp.version}</version>
            </dependency>
            <dependency>
                <groupId>org.jupnp</groupId>
                <artifactId>org.jupnp.support</artifactId>
                <version>${jupnp.version}</version>
            </dependency>
            <!-- Hazelcast -->
            <dependency>
                <groupId>com.hazelcast</groupId>
                <artifactId>hazelcast</artifactId>
                <version>${hazelcast.version}</version>
            </dependency>
            <dependency>
                <groupId>com.hazelcast</groupId>
                <artifactId>hazelcast-spring</artifactId>
                <version>${hazelcast.version}</version>
            </dependency>

            <!-- MapStruct -->
            <dependency>
                <groupId>org.mapstruct</groupId>
                <artifactId>mapstruct</artifactId>
                <version>${mapstruct.version}</version>
            </dependency>
            <dependency>
                <groupId>org.mapstruct</groupId>
                <artifactId>mapstruct-processor</artifactId>
                <version>${mapstruct.version}</version>
            </dependency>

            <!-- API Documentation -->
            <dependency>
                <groupId>org.springdoc</groupId>
                <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
                <version>${springdoc.version}</version>
            </dependency>

            <!-- Security -->
            <dependency>
                <groupId>com.nimbusds</groupId>
                <artifactId>nimbus-jose-jwt</artifactId>
                <version>${nimbus-jose-jwt.version}</version>
            </dependency>
            <dependency>
                <groupId>dev.samstevens.totp</groupId>
                <artifactId>totp</artifactId>
                <version>${totp.version}</version>
            </dependency>
            <dependency>
                <groupId>nl.martijndwars</groupId>
                <artifactId>web-push</artifactId>
                <version>${web-push.version}</version>
            </dependency>
            <dependency>
                <groupId>org.bouncycastle</groupId>
                <artifactId>bcprov-jdk18on</artifactId>
                <version>${bouncycastle.version}</version>
            </dependency>
            <dependency>
                <groupId>org.bitbucket.b_c</groupId>
                <artifactId>jose4j</artifactId>
                <version>${jose4j.version}</version>
            </dependency>
            <!-- web-push's HTTP client, not managed by the Spring Boot BOM (same version web-push declares). -->
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpasyncclient</artifactId>
                <version>4.1.5</version>
            </dependency>

            <!-- Database -->
            <dependency>
                <groupId>org.postgresql</groupId>
                <artifactId>postgresql</artifactId>
                <version>${postgresql.version}</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate.orm</groupId>
                <artifactId>hibernate-community-dialects</artifactId>
                <version>${hibernate.version}</version>
            </dependency>
            <dependency>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-core</artifactId>
                <version>${liquibase.version}</version>
            </dependency>

            <!-- Torrent engine (libtorrent4j). The base artifact carries the Java/SWIG
                 API; each per-platform artifact carries only the native binary and depends
                 on the base. Bundling all three desktop natives makes any build self-contained. -->
            <dependency>
                <groupId>org.libtorrent4j</groupId>
                <artifactId>libtorrent4j</artifactId>
                <version>${libtorrent4j.version}</version>
            </dependency>
            <dependency>
                <groupId>org.libtorrent4j</groupId>
                <artifactId>libtorrent4j-windows</artifactId>
                <version>${libtorrent4j.version}</version>
            </dependency>
            <dependency>
                <groupId>org.libtorrent4j</groupId>
                <artifactId>libtorrent4j-linux</artifactId>
                <version>${libtorrent4j.version}</version>
            </dependency>
            <dependency>
                <groupId>org.libtorrent4j</groupId>
                <artifactId>libtorrent4j-macos</artifactId>
                <version>${libtorrent4j.version}</version>
            </dependency>

            <!-- Override bt-core's transitive Guava 30.1-jre (uses sun.misc.Unsafe). -->
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>${guava.version}</version>
            </dependency>

            <!-- Native SMB (smbj) storage client. -->
            <dependency>
                <groupId>com.hierynomus</groupId>
                <artifactId>smbj</artifactId>
                <version>${smbj.version}</version>
            </dependency>
            <dependency>
                <groupId>org.jmdns</groupId>
                <artifactId>jmdns</artifactId>
                <version>${jmdns.version}</version>
            </dependency>

            <!-- Enforcer convergence pins: align transitive version conflicts. -->
            <!-- spring-modulith-core brings 1.4.2, archunit-junit5 (tests) requires the newer one. -->
            <dependency>
                <groupId>com.tngtech.archunit</groupId>
                <artifactId>archunit</artifactId>
                <version>${archunit.version}</version>
            </dependency>
            <!-- swagger-core-jakarta requires 3.20.0; Boot manages 3.19.0. -->
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>3.21.0</version>
            </dependency>
            <!-- zxing javase brings 1.72, web-push brings 1.78. -->
            <dependency>
                <groupId>com.beust</groupId>
                <artifactId>jcommander</artifactId>
                <version>1.82</version>
            </dependency>
            <!-- caffeine 3.2.4 (Boot 4.0.8) brings 2.49.0, guava 33.6 requires 2.47.0. -->
            <dependency>
                <groupId>com.google.errorprone</groupId>
                <artifactId>error_prone_annotations</artifactId>
                <version>2.51.0</version>
            </dependency>
            <!-- liquibase-core uses 1.15.0 directly, opencsv brings 1.13.1. -->
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-text</artifactId>
                <version>1.15.0</version>
            </dependency>
            <!-- liquibase-core 5.0.4 needs 4.6.0, its opencsv 5.12.0 still declares 4.5.0. -->
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-collections4</artifactId>
                <version>4.6.0</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>flatten-maven-plugin</artifactId>
                    <version>1.8.0</version>
                    <configuration>
                        <updatePomFile>true</updatePomFile>
                        <flattenMode>resolveCiFriendliesOnly</flattenMode>
                    </configuration>
                    <executions>
                        <execution>
                            <id>flatten</id>
                            <phase>process-resources</phase>
                            <goals><goal>flatten</goal></goals>
                        </execution>
                        <execution>
                            <id>flatten.clean</id>
                            <phase>clean</phase>
                            <goals><goal>clean</goal></goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>com.google.cloud.tools</groupId>
                    <artifactId>jib-maven-plugin</artifactId>
                    <version>3.5.2</version>
                    <configuration>
                        <skip>${jib.skip}</skip>
                        <from>
                            <image>${jib.from.image}</image>
                            <!-- База лежит в приватном проекте apps Harbor. ci-templates/maven-app передаёт
                                 учётку только для push (jib.to.auth.*) — pull той же учёткой. -->
                            <auth>
                                <username>${jib.to.auth.username}</username>
                                <password>${jib.to.auth.password}</password>
                            </auth>
                        </from>
                        <to><image>harbor.home.arpa/apps/${project.artifactId}</image></to>
                        <container>
                            <mainClass>${start-class}</mainClass>
                            <ports><port>8080</port></ports>
                            <!-- Совпадает с useradd в docker/base/Dockerfile; /data принадлежит этому uid. -->
                            <user>1000:1000</user>
                            <jvmFlags>
                                <jvmFlag>--enable-native-access=ALL-UNNAMED</jvmFlag>
                                <!-- Куча от лимита памяти контейнера (helm-service: limits.memory = requests.memory). -->
                                <jvmFlag>-XX:MaxRAMPercentage=75</jvmFlag>
                                <jvmFlag>-XX:+ExitOnOutOfMemoryError</jvmFlag>
                            </jvmFlags>
                            <environment>
                                <!-- libtorrent (mmap, try_signal) перехватывает SIGSEGV/SIGBUS поверх JVM —
                                     libjsig выстраивает нативные обработчики за JVM-ным. Дублирует ENV базового
                                     образа: Jib не наследует ENV при явном <environment>. -->
                                <LD_PRELOAD>/opt/java/openjdk/lib/libjsig.so</LD_PRELOAD>
                                <MOORHAVEN_HOME>/data</MOORHAVEN_HOME>
                                <SPRING_DOCKER_COMPOSE_ENABLED>false</SPRING_DOCKER_COMPOSE_ENABLED>
                            </environment>
                            <volumes><volume>/data</volume></volumes>
                            <workingDirectory>/data</workingDirectory>
                            <creationTime>USE_CURRENT_TIMESTAMP</creationTime>
                        </container>
                        <allowInsecureRegistries>true</allowInsecureRegistries>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>${java.version}</source>
                        <target>${java.version}</target>
                        <!-- Treat javac warnings as build-breaking errors. The
                             'processing' category is excluded: marker/runtime
                             annotations (Spring Modulith, MapStruct @MapperConfig)
                             are intentionally not claimed by an annotation processor. -->
                        <compilerArgs>
                            <arg>-Xlint:all,-processing</arg>
                            <arg>-Werror</arg>
                        </compilerArgs>
                        <annotationProcessorPaths>
                            <path>
                                <groupId>org.projectlombok</groupId>
                                <artifactId>lombok</artifactId>
                                <version>${lombok.version}</version>
                            </path>
                            <path>
                                <groupId>org.mapstruct</groupId>
                                <artifactId>mapstruct-processor</artifactId>
                                <version>${mapstruct.version}</version>
                            </path>
                            <path>
                                <groupId>org.projectlombok</groupId>
                                <artifactId>lombok-mapstruct-binding</artifactId>
                                <version>${lombok-mapstruct-binding.version}</version>
                            </path>
                        </annotationProcessorPaths>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-checkstyle-plugin</artifactId>
                    <version>${checkstyle-plugin.version}</version>
                    <dependencies>
                        <dependency>
                            <groupId>com.puppycrawl.tools</groupId>
                            <artifactId>checkstyle</artifactId>
                            <version>${checkstyle.version}</version>
                        </dependency>
                    </dependencies>
                    <configuration>
                        <configLocation>${maven.multiModuleProjectDirectory}/check-code.xml</configLocation>
                        <suppressionsLocation>${maven.multiModuleProjectDirectory}/checkstyle-suppressions.xml</suppressionsLocation>
                        <consoleOutput>true</consoleOutput>
                        <failsOnError>true</failsOnError>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>${enforcer-plugin.version}</version>
                </plugin>

                <!-- Mutation testing. Config lives here so the goal runs consistently in
                     any module (e.g. ad-hoc 'mvn org.pitest:pitest-maven:mutationCoverage'
                     with -DtargetClasses=...); the 'mutation' profile wires it to a phase.
                     JUnit 5 plugin because Spring Boot 4 runs on JUnit Jupiter. -->
                <plugin>
                    <groupId>org.pitest</groupId>
                    <artifactId>pitest-maven</artifactId>
                    <version>${pitest-maven.version}</version>
                    <dependencies>
                        <dependency>
                            <groupId>org.pitest</groupId>
                            <artifactId>pitest-junit5-plugin</artifactId>
                            <version>${pitest-junit5.version}</version>
                        </dependency>
                    </dependencies>
                    <configuration>
                        <targetClasses>
                            <param>com.netmoor.moorhaven.*</param>
                        </targetClasses>
                        <outputFormats>
                            <param>HTML</param>
                            <param>XML</param>
                        </outputFormats>
                        <timestampedReports>false</timestampedReports>
                        <!-- Most modules have no tests yet; skip them instead of failing. -->
                        <failWhenNoMutations>false</failWhenNoMutations>
                        <threads>4</threads>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${jacoco.version}</version>
                    <configuration>
                        <!-- Non-logic code kept out of the coverage denominator. Lombok
                             boilerplate and record members are excluded automatically
                             (@lombok.Generated via lombok.config; record filtering in 0.8.9+). -->
                        <excludes>
                            <exclude>**/*Application.*</exclude>
                            <exclude>**/*MapperImpl.*</exclude>
                        </excludes>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>flatten-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>${skip.module.tests}</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <executions>
                    <execution>
                        <id>checkstyle-check</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Code formatting: palantir-java-format (4-space indent, 120 cols) lays
                 long record-component and parameter lists out one per line. Run
                 'spotless:apply' to format; 'spotless:check' fails the build on drift. -->
            <plugin>
                <groupId>com.diffplug.spotless</groupId>
                <artifactId>spotless-maven-plugin</artifactId>
                <version>${spotless-plugin.version}</version>
                <configuration>
                    <java>
                        <palantirJavaFormat>
                            <version>${palantir-format.version}</version>
                        </palantirJavaFormat>
                    </java>
                </configuration>
                <executions>
                    <execution>
                        <id>spotless-check</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Dependency hygiene: fail the build on version conflicts in the
                 transitive graph, duplicate-declared versions, or a resolved
                 version lower than one a dependency requires. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                    <execution>
                        <id>enforce-dependencies</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireMavenVersion>
                                    <version>[3.9,)</version>
                                </requireMavenVersion>
                                <requireJavaVersion>
                                    <version>[${java.version},)</version>
                                </requireJavaVersion>
                                <banDuplicatePomDependencyVersions/>
                                <requireUpperBoundDeps/>
                                <dependencyConvergence/>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- Platform profiles: choose which native payload the fat jar carries. Use at most one, e.g.
             mvn -Pnative-linux-arm64 package; with none the build is 'native-all'. They combine freely
             with the cluster/standalone profiles. -->
        <!-- Every platform's natives (the default: dev and CI). Same values as the base properties; selectable explicitly. -->
        <profile>
            <id>native-all</id>
            <properties>
                <native.libtorrent4j.windows.scope>runtime</native.libtorrent4j.windows.scope>
                <native.libtorrent4j.linux.scope>runtime</native.libtorrent4j.linux.scope>
                <native.libtorrent4j.macos.scope>runtime</native.libtorrent4j.macos.scope>
                <native.onnxruntime.excludes>${native.onnxruntime.base-excludes}</native.onnxruntime.excludes>
                <native.sqlite.excludes>${native.sqlite.base-excludes}</native.sqlite.excludes>
            </properties>
        </profile>

        <!-- Windows x86_64 only. -->
        <profile>
            <id>native-win-x64</id>
            <properties>
                <native.libtorrent4j.windows.scope>runtime</native.libtorrent4j.windows.scope>
                <native.libtorrent4j.linux.scope>test</native.libtorrent4j.linux.scope>
                <native.libtorrent4j.macos.scope>test</native.libtorrent4j.macos.scope>
                <native.slim.install.skip>true</native.slim.install.skip>
                <native.onnxruntime.excludes>${native.onnxruntime.base-excludes},${native.onnxruntime.ex.linux-x64},${native.onnxruntime.ex.linux-aarch64},${native.onnxruntime.ex.osx-x64},${native.onnxruntime.ex.osx-aarch64}</native.onnxruntime.excludes>
                <native.sqlite.excludes>${native.sqlite.base-excludes},${native.sqlite.ex.foreign-os},${native.sqlite.ex.linux},${native.sqlite.ex.mac},${native.sqlite.ex.windows-not-x64}</native.sqlite.excludes>
            </properties>
        </profile>

        <!-- Linux x86_64 (glibc) only. -->
        <profile>
            <id>native-linux-x64</id>
            <properties>
                <native.libtorrent4j.windows.scope>test</native.libtorrent4j.windows.scope>
                <native.libtorrent4j.linux.scope>runtime</native.libtorrent4j.linux.scope>
                <native.libtorrent4j.macos.scope>test</native.libtorrent4j.macos.scope>
                <native.slim.install.skip>true</native.slim.install.skip>
                <native.onnxruntime.excludes>${native.onnxruntime.base-excludes},${native.onnxruntime.ex.linux-aarch64},${native.onnxruntime.ex.osx-x64},${native.onnxruntime.ex.osx-aarch64},${native.onnxruntime.ex.win-x64}</native.onnxruntime.excludes>
                <native.sqlite.excludes>${native.sqlite.base-excludes},${native.sqlite.ex.foreign-os},${native.sqlite.ex.windows},${native.sqlite.ex.mac},${native.sqlite.ex.linux-minor-arch},${native.sqlite.ex.linux-arm64}</native.sqlite.excludes>
            </properties>
        </profile>

        <!-- Linux aarch64 (glibc) only. libtorrent4j-linux carries only 32-bit ARM, so no libtorrent4j native is bundled and the torrent engine stays disabled (#10). -->
        <profile>
            <id>native-linux-arm64</id>
            <properties>
                <native.libtorrent4j.windows.scope>test</native.libtorrent4j.windows.scope>
                <native.libtorrent4j.linux.scope>test</native.libtorrent4j.linux.scope>
                <native.libtorrent4j.macos.scope>test</native.libtorrent4j.macos.scope>
                <native.slim.install.skip>true</native.slim.install.skip>
                <native.onnxruntime.excludes>${native.onnxruntime.base-excludes},${native.onnxruntime.ex.linux-x64},${native.onnxruntime.ex.osx-x64},${native.onnxruntime.ex.osx-aarch64},${native.onnxruntime.ex.win-x64}</native.onnxruntime.excludes>
                <native.sqlite.excludes>${native.sqlite.base-excludes},${native.sqlite.ex.foreign-os},${native.sqlite.ex.windows},${native.sqlite.ex.mac},${native.sqlite.ex.linux-minor-arch},${native.sqlite.ex.linux-x64}</native.sqlite.excludes>
            </properties>
        </profile>

        <!-- macOS Apple Silicon only. -->
        <profile>
            <id>native-macos-arm64</id>
            <properties>
                <native.libtorrent4j.windows.scope>test</native.libtorrent4j.windows.scope>
                <native.libtorrent4j.linux.scope>test</native.libtorrent4j.linux.scope>
                <native.libtorrent4j.macos.scope>runtime</native.libtorrent4j.macos.scope>
                <native.slim.install.skip>true</native.slim.install.skip>
                <native.onnxruntime.excludes>${native.onnxruntime.base-excludes},${native.onnxruntime.ex.linux-x64},${native.onnxruntime.ex.linux-aarch64},${native.onnxruntime.ex.osx-x64},${native.onnxruntime.ex.win-x64}</native.onnxruntime.excludes>
                <native.sqlite.excludes>${native.sqlite.base-excludes},${native.sqlite.ex.foreign-os},${native.sqlite.ex.windows},${native.sqlite.ex.linux},${native.sqlite.ex.mac-x64}</native.sqlite.excludes>
            </properties>
        </profile>

        <!-- macOS Intel only. libtorrent4j-macos carries only arm64, so no libtorrent4j native is bundled and the torrent engine stays disabled (#10). -->
        <profile>
            <id>native-macos-x64</id>
            <properties>
                <native.libtorrent4j.windows.scope>test</native.libtorrent4j.windows.scope>
                <native.libtorrent4j.linux.scope>test</native.libtorrent4j.linux.scope>
                <native.libtorrent4j.macos.scope>test</native.libtorrent4j.macos.scope>
                <native.slim.install.skip>true</native.slim.install.skip>
                <native.onnxruntime.excludes>${native.onnxruntime.base-excludes},${native.onnxruntime.ex.linux-x64},${native.onnxruntime.ex.linux-aarch64},${native.onnxruntime.ex.osx-aarch64},${native.onnxruntime.ex.win-x64}</native.onnxruntime.excludes>
                <native.sqlite.excludes>${native.sqlite.base-excludes},${native.sqlite.ex.foreign-os},${native.sqlite.ex.windows},${native.sqlite.ex.linux},${native.sqlite.ex.mac-arm64}</native.sqlite.excludes>
            </properties>
        </profile>

        <!-- Static security analysis: SpotBugs + FindSecBugs. Opt-in via
             'mvn -Psecurity verify'. Fails on HIGH-confidence findings of any rank;
             MEDIUM/LOW are reported in target/spotbugsXml.xml. See doc/security-standards.md. -->
        <profile>
            <id>security</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.spotbugs</groupId>
                        <artifactId>spotbugs-maven-plugin</artifactId>
                        <version>4.10.5.0</version>
                        <configuration>
                            <effort>Max</effort>
                            <threshold>High</threshold>
                            <failOnError>true</failOnError>
                            <includeTests>false</includeTests>
                            <xmlOutput>true</xmlOutput>
                            <excludeFilterFile>${maven.multiModuleProjectDirectory}/spotbugs-exclude.xml</excludeFilterFile>
                            <plugins>
                                <plugin>
                                    <groupId>com.h3xstream.findsecbugs</groupId>
                                    <artifactId>findsecbugs-plugin</artifactId>
                                    <version>1.14.0</version>
                                </plugin>
                            </plugins>
                        </configuration>
                        <!-- SpotBugs 4.9.3 bundles an ASM that predates Java 25 class files
                             (major 69); pin a newer ASM so analysis does not abort. -->
                        <dependencies>
                            <dependency>
                                <groupId>org.ow2.asm</groupId>
                                <artifactId>asm</artifactId>
                                <version>9.11.1</version>
                            </dependency>
                            <dependency>
                                <groupId>org.ow2.asm</groupId>
                                <artifactId>asm-tree</artifactId>
                                <version>9.11.1</version>
                            </dependency>
                            <dependency>
                                <groupId>org.ow2.asm</groupId>
                                <artifactId>asm-analysis</artifactId>
                                <version>9.11.1</version>
                            </dependency>
                            <dependency>
                                <groupId>org.ow2.asm</groupId>
                                <artifactId>asm-commons</artifactId>
                                <version>9.11.1</version>
                            </dependency>
                            <dependency>
                                <groupId>org.ow2.asm</groupId>
                                <artifactId>asm-util</artifactId>
                                <version>9.11.1</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <id>spotbugs-check</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <!-- Mutation testing (PIT). Opt-in and inherited by every module, so
             'mvn -Pmutation test' runs mutationCoverage across the reactor; reports
             land in each module's target/pit-reports. Scope a run with, e.g.,
             '-pl moorhaven-media-library -DtargetClasses=...' since PIT is slow,
             especially on @SpringBootTest-heavy modules. -->
        <profile>
            <id>mutation</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.pitest</groupId>
                        <artifactId>pitest-maven</artifactId>
                        <executions>
                            <execution>
                                <id>pit-mutation-coverage</id>
                                <phase>test</phase>
                                <goals>
                                    <goal>mutationCoverage</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Code coverage (JaCoCo). Opt-in and inherited by every module: attaches the
             coverage agent during the test phase, so each module writes target/jacoco.exec.
             The moorhaven-coverage module then merges them into a reactor-wide report.
             Run: 'mvn -Pcoverage verify' → moorhaven-coverage/target/site/jacoco-aggregate.
             On by default: the platform CI runs a plain `mvn verify` (ci-templates/maven-app), and the
             jacoco.min ratchet must block there. -Dskip.coverage=true turns it off for a quick local run. -->
        <profile>
            <id>coverage</id>
            <activation>
                <property>
                    <name>!skip.coverage</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>jacoco-prepare-agent</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                            </execution>
                            <!-- Per-module HTML/XML report (target/site/jacoco/), the source
                                 for doc/coverage-baseline.md and for eyeballing gaps locally. -->
                            <execution>
                                <id>jacoco-report</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                            </execution>
                            <!-- Ratchet gate: fail 'verify' if a module drops below its
                                 jacoco.min line ratio. Default 0.00 = no-op until a module
                                 opts in by raising jacoco.min in its own POM. -->
                            <execution>
                                <id>jacoco-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>${jacoco.min}</minimum>
                                                </limit>
                                            </limits>
                                        </rule>
                                    </rules>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
