<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.tuladb</groupId>
  <artifactId>tuladb-client</artifactId>
  <!-- Keep in sync with the repo-root VERSION file (single source of truth). -->
  <version>0.0.1-preview</version>
  <name>TulaDB Java SDK</name>
  <description>Raw Java client SDK for TulaDB ledgerd.</description>
  <url>https://tuladb.com</url>
  <licenses>
    <license>
      <name>TulaDB Source-Available License</name>
      <url>https://tuladb.com/licensing</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <developers>
    <developer>
      <id>tuladb</id>
      <name>TulaDB</name>
      <organization>TulaDB</organization>
      <organizationUrl>https://tuladb.com</organizationUrl>
    </developer>
  </developers>
  <scm>
    <connection>scm:git:https://github.com/TulaDB/tuladb-sdk.git</connection>
    <developerConnection>scm:git:ssh://git@github.com/TulaDB/tuladb-sdk.git</developerConnection>
    <url>https://github.com/TulaDB/tuladb-sdk</url>
  </scm>
  <properties>
    <maven.compiler.release>21</maven.compiler.release>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <build>
    <testSourceDirectory>src/test/java</testSourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.14.1</version>
        <configuration>
          <release>${maven.compiler.release}</release>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>3.1.0</version>
        <configuration>
          <mainClass>com.tuladb.CodecTest</mainClass>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <!-- Release profile: builds SIGNED main + sources + javadoc jars and
         publishes them to the Sonatype Central Portal. Opt-in
         (`mvn -Prelease deploy`) so ordinary dev/CI builds skip signing and
         javadoc. Requires a GPG key on the runner and a `central` server entry
         in settings.xml — the SDK release workflow provisions both. -->
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>3.3.1</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>3.8.0</version>
            <configuration>
              <doclint>none</doclint>
            </configuration>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals><goal>jar</goal></goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <!-- Maven Central mandates GPG-signed artifacts (.asc). -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>3.2.7</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals><goal>sign</goal></goals>
                <configuration>
                  <!-- Non-interactive signing in CI (gpg 2.1+ loopback mode). -->
                  <gpgArguments>
                    <arg>--pinentry-mode</arg>
                    <arg>loopback</arg>
                  </gpgArguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <!-- Uploads to the Central Portal; `central` matches the server id
                 the release workflow writes into ~/.m2/settings.xml. -->
            <groupId>org.sonatype.central</groupId>
            <artifactId>central-publishing-maven-plugin</artifactId>
            <version>0.8.0</version>
            <extensions>true</extensions>
            <configuration>
              <publishingServerId>central</publishingServerId>
              <!-- Publish automatically once Central validation passes (no manual
                   "Publish" click in the Portal). waitUntil=published makes the
                   build block until it is actually live, so the job only succeeds
                   on a real publish. Remove autoPublish to stage for manual review. -->
              <autoPublish>true</autoPublish>
              <waitUntil>published</waitUntil>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
