<?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-lifecycle</artifactId>
    <packaging>jar</packaging>

    <name>Exeris SDK :: Composition Lifecycle</name>
    <description>
        The cap-facing four-phase lifecycle hooks interface (ADR-024 obligation 8a):
        CapabilityLifecycleHooks — initialize / ready / drain / terminate — implemented by a cap's
        @CapabilityLifecycle owner and driven by the boot conductor in exeris-sdk-composition-runtime.
        Zero dependencies by contract: cap authors compile against exeris-sdk-annotations + this jar
        only, with no Jackson (or anything else) dragged onto their classpath.
    </description>

    <dependencies>
        <!-- Test-only. The published artifact has ZERO compile/runtime dependencies (see the
             enforcer rule below) — that is the module's charter, not an accident. -->
        <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>
    </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 gate. The default no-op methods are the published contract
                 ("implement the subset you need") — the contract test exercises their bytecode. -->
            <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>

            <!-- Zero-dependency guard — the ban-javaparser twin, but stronger: this module bans ALL
                 compile/runtime-scope dependencies (transitives included). Cap authors implementing
                 CapabilityLifecycleHooks must get nothing but this jar on their classpath — no
                 Jackson, no spec records, nothing. Test scope is exempt (junit/assertj only). -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                    <execution>
                        <id>ban-all-non-test-deps-zero-coupling</id>
                        <phase>verify</phase>
                        <goals><goal>enforce</goal></goals>
                        <configuration>
                            <rules>
                                <bannedDependencies>
                                    <!-- Ban everything… -->
                                    <excludes>
                                        <exclude>*</exclude>
                                    </excludes>
                                    <!-- …except test scope (pattern: groupId:artifactId:version:type:scope). -->
                                    <includes>
                                        <include>*:*:*:*:test</include>
                                    </includes>
                                    <message>exeris-sdk-composition-lifecycle must have ZERO compile/runtime dependencies — cap authors compile against exeris-sdk-annotations + this jar only (ADR-024 obligation 8a). Only test-scope dependencies are allowed.</message>
                                </bannedDependencies>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
