<?xml version="1.0" encoding="UTF-8"?>
<!--
  Java artifact build for the aim2be observability proto contracts.

  Produces `com.aim2be:proto-observability:<ver>` — the buf-defined
  observability/v1/error_event.proto (ErrorEvent + RecoveryAction, ADR-0013 §3)
  compiled to Java via protobuf-maven-plugin and published to the Forgejo
  affinity-intelligence-rework Maven package registry. The 8 Java services in the
  #332 OTEL sweep consume this as a normal Maven dependency (same channel as
  im2be-platform-libs, CONT-3 Option A) rather than vendoring the .proto per
  service — ErrorEvent is messages-only (no gRPC) and shared by every service, so
  a single published jar is the source of truth.

  buf (buf.yaml / buf.gen.yaml) remains authoritative for lint + breaking-change
  gates + TS/Python codegen; this POM is solely the Java distribution path.
-->
<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>

    <groupId>com.aim2be</groupId>
    <artifactId>proto-observability</artifactId>
    <!-- Fixed (immutable) release: the first consumer wires this in W1 PR-OTEL-1,
         so the shared contract must not change bytes under a stable coordinate.
         Additive changes (new optional field) → 1.1.0 (buf WIRE_JSON guards
         backward compat); field removal/renumber → observability/v2 + 2.0.0. -->
    <version>1.0.0</version>
    <packaging>jar</packaging>
    <name>im2be proto-observability (Java)</name>
    <description>
        Java codegen of the aim2be observability proto contracts (ErrorEvent +
        RecoveryAction per ADR-0013 §3). Published to the Forgejo
        affinity-intelligence-rework Maven registry; consumed by the Java services
        instrumented in the #332 OTEL sweep.
    </description>

    <properties>
        <maven.compiler.release>17</maven.compiler.release>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <!-- Pinned (rule 9). protobuf 3.25.5 matches the version identity-service
             and the other Java services already resolve, so the generated
             messages link against one consistent protobuf-java runtime. -->
        <protobuf.version>3.25.5</protobuf.version>
        <protobuf.plugin.version>0.6.1</protobuf.plugin.version>
        <os.plugin.version>1.7.1</os.plugin.version>
    </properties>

    <dependencies>
        <!-- Runtime for the generated message classes. No grpc — messages only. -->
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <version>${protobuf.version}</version>
        </dependency>
    </dependencies>

    <distributionManagement>
        <repository>
            <id>forgejo-air</id>
            <name>Forgejo affinity-intelligence-rework Maven registry</name>
            <url>https://git.hemoglobina.store/api/packages/affinity-intelligence-rework/maven</url>
        </repository>
        <snapshotRepository>
            <id>forgejo-air</id>
            <name>Forgejo affinity-intelligence-rework Maven registry (snapshots)</name>
            <url>https://git.hemoglobina.store/api/packages/affinity-intelligence-rework/maven</url>
        </snapshotRepository>
    </distributionManagement>

    <build>
        <!-- os-maven-plugin extension feeds protoc-${os.detected.classifier} so
             the protoc binary matches the build host. Required by
             protobuf-maven-plugin. -->
        <extensions>
            <extension>
                <groupId>kr.motd.maven</groupId>
                <artifactId>os-maven-plugin</artifactId>
                <version>${os.plugin.version}</version>
            </extension>
        </extensions>

        <plugins>
            <!-- protobuf-maven-plugin — compiles observability/v1/*.proto → Java.
                 Same toolchain as identity-service / realtime-service, minus the
                 grpc `compile-custom` goal (this contract has no services). -->
            <plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
                <version>${protobuf.plugin.version}</version>
                <configuration>
                    <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
                    <!-- Proto sources live at the repo root (observability/v1/*.proto)
                         — buf's layout — not the plugin default src/main/proto. The
                         well-known google/protobuf/timestamp.proto import resolves
                         from protoc's bundled includes. -->
                    <protoSourceRoot>${project.basedir}</protoSourceRoot>
                    <!-- Bound the compile scope to the observability tree. Without
                         this, the default **/*.proto glob over the repo root would
                         silently compile + ship any future stray .proto (a v2 draft,
                         a fixture). The repo-root protoSourceRoot is kept so the
                         import path observability/v1/error_event.proto stays valid. -->
                    <includes>
                        <include>observability/**/*.proto</include>
                    </includes>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
