<?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
             https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.micro-manager</groupId>
  <artifactId>MM-OME-Zarr-Storage</artifactId>
  <version>0.1.0</version>
  <packaging>jar</packaging>

  <name>MM-OME-Zarr-Storage</name>
  <description>High-performance streaming OME-Zarr (OME-NGFF v0.5 / Zarr v3) writer and
    reader with multiscale pyramid support and concurrent read-while-write. Modeled on
    NDTiffStorage; no dependency on Micro-Manager.</description>
  <url>https://github.com/micro-manager/MM-OME-Zarr-Storage</url>

  <licenses>
    <license>
      <name>BSD 3-Clause License</name>
      <url>https://opensource.org/licenses/BSD-3-Clause</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <developers>
    <developer>
      <id>nicost</id>
      <name>Nico Stuurman</name>
      <url>https://github.com/nicost</url>
      <organization>Micro-Manager</organization>
      <organizationUrl>https://micro-manager.org</organizationUrl>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:https://github.com/micro-manager/MM-OME-Zarr-Storage.git</connection>
    <developerConnection>scm:git:ssh://git@github.com/micro-manager/MM-OME-Zarr-Storage.git</developerConnection>
    <url>https://github.com/micro-manager/MM-OME-Zarr-Storage</url>
    <tag>HEAD</tag>
  </scm>

  <properties>
    <!-- Target Java 8 so the jar is usable from the Micro-Manager build (which is Java 8).
         The source uses no Java 9+ APIs, and all dependencies (zarr-java, cdm-core, jackson)
         are Java 8 bytecode. -->
    <maven.compiler.release>8</maven.compiler.release>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <junit.version>5.10.2</junit.version>
    <jackson.version>2.17.1</jackson.version>
  </properties>

  <dependencies>

    <!-- Zarr v3 read/write engine (pure Java) -->
    <dependency>
      <groupId>dev.zarr</groupId>
      <artifactId>zarr-java</artifactId>
      <version>0.0.4</version>
      <!-- zarr-java pulls in the AWS SDK for its optional S3Store backend, which this library
           never uses (it uses FilesystemStore only). Excluding it here keeps the AWS SDK
           (~15 MB) off every downstream consumer's classpath. S3Store.class remains in the
           zarr-java jar but is never loaded, so its unresolved AWS references are inert. -->
      <exclusions>
        <exclusion>
          <groupId>com.amazonaws</groupId>
          <artifactId>*</artifactId>
        </exclusion>
        <exclusion>
          <groupId>software.amazon.ion</groupId>
          <artifactId>ion-java</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- JSON (de)serialization for OME-NGFF attributes and metadata sidecars -->
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>${jackson.version}</version>
    </dependency>

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

  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.11.0</version>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.2.5</version>
      </plugin>

      <!-- Maven Central requires a sources jar alongside the main artifact. -->
      <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>

      <!-- Maven Central requires a javadoc jar alongside the main artifact.
           doclint is disabled: Central only requires that a javadoc jar is
           attached, not that every method has complete @param/@return tags.
           Without this, the strict doclint fails the build on missing tags. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.6.3</version>
        <configuration>
          <doclint>none</doclint>
        </configuration>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals><goal>jar</goal></goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <!--
    Release profile: signs every artifact with GPG and publishes to the Sonatype
    Central Portal. Activate with `mvn -Prelease deploy`. Kept in a profile so
    ordinary `mvn package` / `mvn install` builds don't require a GPG key.
  -->
  <profiles>
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <!-- Sign all artifacts (jar, sources, javadoc, pom) with GPG. -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>3.2.4</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals><goal>sign</goal></goals>
                <configuration>
                  <!-- Non-interactive signing for CI: read the passphrase from the
                       gpg.passphrase property (supplied via -D or the GITHUB env) and
                       use loopback pinentry so gpg never tries to prompt on a tty.
                       Harmless for local interactive signing via the gpg-agent. -->
                  <gpgArguments>
                    <arg>--pinentry-mode</arg>
                    <arg>loopback</arg>
                  </gpgArguments>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <!-- Upload the signed bundle to the Sonatype Central Portal. -->
          <plugin>
            <groupId>org.sonatype.central</groupId>
            <artifactId>central-publishing-maven-plugin</artifactId>
            <version>0.7.0</version>
            <extensions>true</extensions>
            <configuration>
              <publishingServerId>central</publishingServerId>
              <autoPublish>true</autoPublish>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
