Class CentralDeploySentinel

java.lang.Object
network.ike.plugin.CentralDeploySentinel

public final class CentralDeploySentinel extends Object
Status record for an asynchronous Maven Central deploy (IKE-Network/ike-issues#484). Persisted as a Java .properties file under a discoverable cache directory so the outcome survives the originating Maven JVM exiting.

State machine (single forward transition): CentralDeploySentinel.State.PENDING is written by the release Mojo when it spawns the detached subprocess; the subprocess itself rewrites the file to CentralDeploySentinel.State.SUCCESS or CentralDeploySentinel.State.FAILURE when it finishes.

Default location: ~/.cache/ike-release/. Chosen over target/ so the sentinel survives a mvn clean and is discoverable across repos by CentralStatusMojo, which walks the directory to report in-flight deploys workspace-wide.

  • Field Details

    • DEFAULT_DIR

      public static final Path DEFAULT_DIR
      Default sentinel directory: ~/.cache/ike-release/.
  • Method Details

    • state

      Lifecycle state of this sentinel.
      Returns:
      the state
    • artifactId

      public String artifactId()
      Project artifactId the deploy belongs to.
      Returns:
      the artifactId
    • version

      public String version()
      Release version being deployed.
      Returns:
      the version
    • started

      public Instant started()
      When the deploy was spawned (UTC).
      Returns:
      the start instant
    • finished

      public Instant finished()
      When the deploy reached a terminal state, or null while still CentralDeploySentinel.State.PENDING.
      Returns:
      the finish instant, or null when pending
    • attempts

      public int attempts()
      Number of attempts taken — refreshed by the subprocess before each upload so ike:central-status reflects live progress.
      Returns:
      attempts taken so far
    • maxAttempts

      public int maxAttempts()
      Configured maximum attempts for the retry loop, recorded so the displayed attempts/max ratio is meaningful even after the configuration changes between releases.
      Returns:
      the configured maximum
    • lastError

      public String lastError()
      Short failure summary captured by the subprocess when the retry budget is exhausted.
      Returns:
      failure summary, or null when not failed
    • logFile

      public Path logFile()
      Path the subprocess streams its deploy log to.
      Returns:
      the log-file path, or null if not recorded
    • pid

      public long pid()
      PID of the spawned subprocess. Written while CentralDeploySentinel.State.PENDING so ike:central-status can detect orphaned sentinels (subprocess died, sentinel never advanced).
      Returns:
      the PID, or 0 if not recorded
    • note

      public String note()
      Advisory note recorded alongside a non-failure outcome — e.g. a SUCCESS where JReleaser's publish poll timed out, so the upload is confirmed but PUBLISHED was never observed. Distinct from lastError(), which is set only on FAILURE.
      Returns:
      the note, or null if none was recorded
    • path

      public Path path()
      Absolute path to this sentinel file on disk.
      Returns:
      the sentinel file path
    • resolvePath

      public static Path resolvePath(Path dir, String artifactId, String version)
      Resolve the canonical sentinel-file path for a project.
      Parameters:
      dir - sentinel directory (typically DEFAULT_DIR)
      artifactId - project artifactId
      version - release version
      Returns:
      <dir>/<artifactId>-<version>.properties
    • read

      public static CentralDeploySentinel read(Path path)
      Read a sentinel file into a value object.
      Parameters:
      path - the sentinel file
      Returns:
      the parsed sentinel
      Throws:
      org.apache.maven.api.plugin.MojoException - if the file is missing or malformed
    • listAll

      public static List<CentralDeploySentinel> listAll(Path dir)
      List all sentinel files under a directory, newest first. Files that fail to parse are skipped — listing must be robust against partially-written files an in-flight subprocess is updating.
      Parameters:
      dir - the sentinel directory (may not exist; treated as empty)
      Returns:
      parsed sentinels, ordered by started descending
    • write

      public void write()
      Write this sentinel to path(). Atomic replace via a temp-file + rename so concurrent readers never see a half-written file.
      Throws:
      org.apache.maven.api.plugin.MojoException - on I/O failure
    • builder

      public static CentralDeploySentinel.Builder builder()
      Start a new, empty builder.
      Returns:
      a fresh builder
    • toBuilder

      public CentralDeploySentinel.Builder toBuilder()
      Start a builder pre-seeded with this sentinel's fields — the typical entry point for the subprocess transitioning CentralDeploySentinel.State.PENDING to CentralDeploySentinel.State.SUCCESS or CentralDeploySentinel.State.FAILURE without restating immutable fields.
      Returns:
      a builder seeded from this sentinel