<?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>

  <groupId>io.github.lightspeed-intelligence</groupId>
  <artifactId>tipsy-ab-config-parent</artifactId>
  <version>0.1.0</version>
  <packaging>pom</packaging>

  <name>Tipsy AB-config Java SDK (parent)</name>
  <description>
    Parent POM for the Tipsy AB-config Java SDK reactor: aggregates the proto,
    auth, main SDK and example modules, and centralizes dependency / plugin
    version management. Mirrors the Go / Python SDK capability surface.
  </description>
  <url>https://github.com/Lightspeed-Intelligence/tipsy-ab-config-sdk</url>

  <!-- Maven Central (Sonatype Central Publisher Portal) requires url /
       licenses / developers / scm on every published artifact; children
       inherit these from the parent. -->
  <licenses>
    <license>
      <name>MIT License</name>
      <url>https://opensource.org/licenses/MIT</url>
    </license>
  </licenses>

  <developers>
    <developer>
      <name>Tipsy AB-config team</name>
      <url>https://github.com/Lightspeed-Intelligence</url>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:git://github.com/Lightspeed-Intelligence/tipsy-ab-config-sdk.git</connection>
    <developerConnection>scm:git:ssh://github.com/Lightspeed-Intelligence/tipsy-ab-config-sdk.git</developerConnection>
    <url>https://github.com/Lightspeed-Intelligence/tipsy-ab-config-sdk</url>
  </scm>

  <modules>
    <module>tipsy-abconfig-proto</module>
    <module>tipsy-auth</module>
    <module>tipsy-abconfig</module>
    <module>example</module>
  </modules>

  <properties>
    <maven.compiler.release>21</maven.compiler.release>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <!-- Dependency versions (pinned; see design 02 version-fix table). -->
    <protobuf.version>4.28.3</protobuf.version>
    <grpc.version>1.68.1</grpc.version>
    <jjwt.version>0.12.6</jjwt.version>
    <slf4j.version>2.0.16</slf4j.version>
    <junit.version>5.11.3</junit.version>
    <mockito.version>5.14.2</mockito.version>
    <annotations-api.version>6.0.53</annotations-api.version>

    <!-- Plugin versions (pinned). -->
    <maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
    <maven-surefire-plugin.version>3.5.2</maven-surefire-plugin.version>
    <maven-shade-plugin.version>3.6.0</maven-shade-plugin.version>
    <maven-deploy-plugin.version>3.1.3</maven-deploy-plugin.version>
    <os-maven-plugin.version>1.7.1</os-maven-plugin.version>
    <protobuf-maven-plugin.version>0.6.1</protobuf-maven-plugin.version>

    <!-- Release plugin versions (pinned; mirror pineapple's release profile). -->
    <maven-source-plugin.version>3.3.1</maven-source-plugin.version>
    <maven-javadoc-plugin.version>3.6.3</maven-javadoc-plugin.version>
    <maven-gpg-plugin.version>3.2.4</maven-gpg-plugin.version>
    <central-publishing-maven-plugin.version>0.7.0</central-publishing-maven-plugin.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <!-- gRPC BOM: aligns all io.grpc:grpc-* artifacts to ${grpc.version}. -->
      <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-bom</artifactId>
        <version>${grpc.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>

      <!-- JUnit 5 BOM: aligns junit-jupiter aggregator + engine. -->
      <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit-bom</artifactId>
        <version>${junit.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>

      <!-- protobuf runtime + protojson util. -->
      <dependency>
        <groupId>com.google.protobuf</groupId>
        <artifactId>protobuf-java</artifactId>
        <version>${protobuf.version}</version>
      </dependency>
      <dependency>
        <groupId>com.google.protobuf</groupId>
        <artifactId>protobuf-java-util</artifactId>
        <version>${protobuf.version}</version>
      </dependency>

      <!-- Individual io.grpc:grpc-* artifacts (grpc-netty-shaded,
           grpc-protobuf, grpc-stub, grpc-inprocess) are NOT redeclared here:
           their managed versions are supplied by the grpc-bom import above.
           Child modules declare them without an explicit <version>. -->

      <!-- Generated-code @Generated/@Override annotation placeholder
           (Java 9+ removed javax.annotation from the JDK). -->
      <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>annotations-api</artifactId>
        <version>${annotations-api.version}</version>
        <scope>provided</scope>
      </dependency>

      <!-- jjwt (tipsy-auth HS256). -->
      <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt-api</artifactId>
        <version>${jjwt.version}</version>
      </dependency>
      <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt-impl</artifactId>
        <version>${jjwt.version}</version>
        <scope>runtime</scope>
      </dependency>
      <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt-gson</artifactId>
        <version>${jjwt.version}</version>
        <scope>runtime</scope>
      </dependency>

      <!-- SLF4J facade (host picks the backend). -->
      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${slf4j.version}</version>
      </dependency>

      <!-- Mockito (test). -->
      <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-core</artifactId>
        <version>${mockito.version}</version>
        <scope>test</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

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

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

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

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

        <!-- os-maven-plugin is used as a build extension (in the proto module)
             to populate ${os.detected.classifier}; managed here for version. -->
        <plugin>
          <groupId>kr.motd.maven</groupId>
          <artifactId>os-maven-plugin</artifactId>
          <version>${os-maven-plugin.version}</version>
        </plugin>

        <plugin>
          <groupId>org.xolstice.maven.plugins</groupId>
          <artifactId>protobuf-maven-plugin</artifactId>
          <version>${protobuf-maven-plugin.version}</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <profiles>
    <!-- release: attach source + javadoc jars, GPG-sign all artifacts, and
         publish to Maven Central via the Sonatype Central Publisher Portal.
         Mirrors ~/pineapple/pine-java's release profile. Activate with -Prelease.
         Inherited by every child module; the example module disables publishing
         (skipPublishing=true in its own POM). Requires a `central` server in
         settings.xml (CENTRAL_USERNAME / CENTRAL_TOKEN) and a GPG key. -->
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>${maven-source-plugin.version}</version>
            <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>
            <version>${maven-javadoc-plugin.version}</version>
            <configuration>
              <doclint>none</doclint>
            </configuration>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>${maven-gpg-plugin.version}</version>
            <configuration>
              <gpgArguments>
                <arg>--pinentry-mode</arg>
                <arg>loopback</arg>
              </gpgArguments>
            </configuration>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.sonatype.central</groupId>
            <artifactId>central-publishing-maven-plugin</artifactId>
            <version>${central-publishing-maven-plugin.version}</version>
            <extensions>true</extensions>
            <configuration>
              <publishingServerId>central</publishingServerId>
              <autoPublish>true</autoPublish>
              <!-- The plugin aggregates the whole reactor and uploads ONE bundle
                   from the last reactor module. Exclude the demo `example` module
                   from that bundle here (instead of skipPublishing on the module,
                   which would suppress the entire upload). The published set is
                   then: parent (pom) + tipsy-abconfig-proto + tipsy-auth +
                   tipsy-abconfig. -->
              <!-- central-publishing 0.7.0 matches each exclude entry against the
                   bare artifactId (Artifact.getArtifactId()), NOT groupId/GAV.
                   So this must be just the artifactId. -->
              <excludeArtifacts>
                <artifact>tipsy-abconfig-example</artifact>
              </excludeArtifacts>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
