<?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>com.govplane</groupId>
  <artifactId>gp-runtime-sdk</artifactId>
  <version>0.1.1</version>
  <packaging>jar</packaging>

  <name>Govplane Runtime SDK</name>
  <description>Java 21 SDK for the Govplane runtime policy engine</description>

  <url>https://github.com/govplane/gp-runtime-sdk</url>

  <licenses>
    <license>
      <name>MIT License</name>
      <url>https://opensource.org/licenses/MIT</url>
    </license>
  </licenses>

  <developers>
    <developer>
      <id>govplane</id>
      <name>Govplane</name>
      <email>dev@govplane.com</email>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:git://github.com/govplane/gp-runtime-sdk.git</connection>
    <developerConnection>scm:git:ssh://github.com/govplane/gp-runtime-sdk.git</developerConnection>
    <url>https://github.com/govplane/gp-runtime-sdk</url>
  </scm>

  <properties>
    <java.version>21</java.version>
    <maven.compiler.source>21</maven.compiler.source>
    <maven.compiler.target>21</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <jackson.version>2.17.2</jackson.version>
    <junit.version>5.10.3</junit.version>
    <mockito.version>5.12.0</mockito.version>
  </properties>

  <dependencies>
    <!-- JSON serialisation / deserialisation -->
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>${jackson.version}</version>
    </dependency>

    <!-- JUnit 5 -->
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>

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

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.13.0</version>
        <configuration>
          <release>21</release>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.3.1</version>
        <configuration>
          <useModulePath>false</useModulePath>
          <argLine>-Dnet.bytebuddy.experimental=true</argLine>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.4.2</version>
        <configuration>
          <archive>
            <manifest>
              <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
            </manifest>
          </archive>
        </configuration>
      </plugin>

      <!-- Generates sources JAR (required by Maven Central) -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>3.3.1</version>
        <executions>
          <execution>
            <goals><goal>jar-no-fork</goal></goals>
          </execution>
        </executions>
      </plugin>

      <!-- Generates javadoc JAR (required by Maven Central) -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.10.1</version>
        <executions>
          <execution>
            <goals><goal>jar</goal></goals>
          </execution>
        </executions>
      </plugin>

      <!-- Produces gp-runtime-sdk-0.1.0-all.jar with all runtime deps bundled -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.6.0</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals><goal>shade</goal></goals>
            <configuration>
              <shadedArtifactAttached>true</shadedArtifactAttached>
              <shadedClassifierName>all</shadedClassifierName>
              <!-- Keep the original pom.xml as the installed/deployed POM so that
                   consumers still receive Jackson as a transitive dependency -->
              <createDependencyReducedPom>false</createDependencyReducedPom>
              <filters>
                <filter>
                  <artifact>*:*</artifact>
                  <excludes>
                    <exclude>META-INF/*.SF</exclude>
                    <exclude>META-INF/*.DSA</exclude>
                    <exclude>META-INF/*.RSA</exclude>
                  </excludes>
                </filter>
              </filters>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Signs all artifacts with GPG (required by Maven Central) -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-gpg-plugin</artifactId>
        <version>3.2.4</version>
        <executions>
          <execution>
            <phase>verify</phase>
            <goals><goal>sign</goal></goals>
            <configuration>
              <passphraseServerId>gpg.passphrase</passphraseServerId>
              <gpgArguments>
                <arg>--pinentry-mode</arg>
                <arg>loopback</arg>
              </gpgArguments>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Publishes to Maven Central via Sonatype Portal -->
      <plugin>
        <groupId>org.sonatype.central</groupId>
        <artifactId>central-publishing-maven-plugin</artifactId>
        <version>0.5.0</version>
        <extensions>true</extensions>
        <configuration>
          <publishingServerId>central</publishingServerId>
          <autoPublish>true</autoPublish>
          <excludeArtifacts>
            <excludeArtifact>gp-runtime-sdk-0.1.0-all.jar</excludeArtifact>
          </excludeArtifacts>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
