<?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-sdk-parent</artifactId>
        <version>0.12.0</version>
        <relativePath>../exeris-sdk-parent</relativePath>
    </parent>

    <artifactId>exeris-sdk-composition-spec</artifactId>
    <packaging>jar</packaging>

    <name>Exeris SDK :: Composition Spec</name>
    <description>
        Single source of truth for the ADR-024 cap-manifest.json schema and content-binding
        algorithm. Shared by the build-time tooling that emits the manifest and the SKU-boot
        runtime that asserts it (obligation 8b). Zero runtime dependencies — pure records plus
        SHA-256; consumers bring their own JSON mapper.
    </description>

    <dependencies>
        <!-- Test-only. The published artifact stays dependency-free so both the tooling
             emitter and the SKU-boot runtime can depend on it without dragging the build
             pipeline or a JSON binder onto each other's classpath. -->
        <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-only. The records are annotation-free by design; this lets the round-trip test
             prove the documented mapper contract (FAIL_ON_UNKNOWN_PROPERTIES=false +
             FAIL_ON_NULL_FOR_PRIMITIVES=false) and that the wire keys match the tooling producer.
             Test scope keeps it off the published artifact's dependency tree, so the zero-coupling
             guarantee — and the ban-javaparser enforcer (compile/runtime only) — is unaffected. -->
        <dependency>
            <groupId>tools.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals><goal>jar-no-fork</goal></goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <!-- These modules carry no javadoc warning at all, so the cheapest possible
                         gate is the real one: any new undocumented public member fails the build
                         here rather than shipping to Maven Central undocumented. exeris-sdk-source-model
                         cannot use this — its builder setters are deliberately undocumented (their
                         components carry the prose) — and is gated by JavadocCompletenessTest instead. -->
                    <failOnWarnings>true</failOnWarnings>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals><goal>jar</goal></goals>
                    </execution>
                </executions>
            </plugin>

            <!-- 85% instruction + line coverage gate. The binding is real logic with a
                 golden-vector contract; coverage is meaningful here. -->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>jacoco-check</id>
                        <phase>verify</phase>
                        <goals><goal>check</goal></goals>
                        <configuration>
                            <rules>
                                <rule>
                                    <element>BUNDLE</element>
                                    <limits>
                                        <limit>
                                            <counter>INSTRUCTION</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>${jacoco.instruction.coverage.minimum}</minimum>
                                        </limit>
                                        <limit>
                                            <counter>LINE</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>${jacoco.line.coverage.minimum}</minimum>
                                        </limit>
                                    </limits>
                                </rule>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- ADR-037 zero-coupling guard: this spec is depended on by both the tooling and
                 the SKU-boot runtime, so it must stay dependency-free — JavaParser (or anything
                 it might transitively pull) must never reach its dependency tree. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                    <execution>
                        <id>ban-javaparser-zero-coupling</id>
                        <phase>verify</phase>
                        <goals><goal>enforce</goal></goals>
                        <configuration>
                            <rules>
                                <bannedDependencies>
                                    <excludes>
                                        <exclude>com.github.javaparser</exclude>
                                    </excludes>
                                    <message>The composition-spec must stay dependency-free — JavaParser must not appear on its dependency tree.</message>
                                </bannedDependencies>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <!-- Semver gate configuration for this module. The bindings, the baseline and the strict
         ruleset are the root pom's opt-in `semver` profile; this profile shares its id, so
         `-Psemver` activates both, and it binds nothing of its own — it only says which record
         here takes the record-growth relaxation.

         This module has exactly one record (CapManifest); everything else is ordinary classes whose
         constructors are real API. A module-wide relaxation would retire a genuine safety net in
         exchange for one record's growth path, so the relaxation is named: the strict execution
         excludes the record and the record-growth execution includes it, accepting
         CONSTRUCTOR_REMOVED as a MINOR change. Removing, renaming or retyping a component still
         breaks through its accessor. exeris-sdk-source-model takes no such relaxation: a record
         there that grows keeps its previous arity as a delegating constructor (see its pom).
         Whether CapManifest moves to that rule is open; see ROADMAP. -->
    <profiles>
        <profile>
            <id>semver</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.siom79.japicmp</groupId>
                        <artifactId>japicmp-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>semver-gate</id>
                                <configuration>
                                    <parameter>
                                        <excludes>
                                            <exclude>eu.exeris.sdk.composition.CapManifest</exclude>
                                        </excludes>
                                    </parameter>
                                </configuration>
                            </execution>
                            <execution>
                                <id>semver-gate-record-growth</id>
                                <configuration>
                                    <skip>${japicmp.skip}</skip>
                                    <parameter>
                                        <includes>
                                            <include>eu.exeris.sdk.composition.CapManifest</include>
                                        </includes>
                                        <overrideCompatibilityChangeParameters>
                                            <overrideCompatibilityChangeParameter>
                                                <compatibilityChange>CONSTRUCTOR_REMOVED</compatibilityChange>
                                                <binaryCompatible>true</binaryCompatible>
                                                <sourceCompatible>true</sourceCompatible>
                                                <semanticVersionLevel>MINOR</semanticVersionLevel>
                                            </overrideCompatibilityChangeParameter>
                                        </overrideCompatibilityChangeParameters>
                                    </parameter>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
