Class ManifestReader

java.lang.Object
network.ike.workspace.ManifestReader

public final class ManifestReader extends Object
Reads a workspace.yaml file into a typed Manifest.

SnakeYAML parses into raw Maps; this class maps the untyped structure onto immutable Java records with validation.

As of #150, the manifest uses the subprojects: top-level key. Legacy manifests with components: are rejected by read(Path) — run mvn ws:align-publish to migrate, or call migrateLegacySchemaIfNeeded(Path, java.util.function.Consumer) first as ws:align-publish does internally.

  • Method Details

    • read

      public static Manifest read(Path path)
      Read a workspace manifest from the given YAML file path.
      Parameters:
      path - path to workspace.yaml
      Returns:
      the parsed manifest
      Throws:
      ManifestException - if the file cannot be read, has invalid structure, or uses the legacy components: schema
    • read

      public static Manifest read(Reader reader)
      Read a workspace manifest from a Reader (useful for testing).
      Parameters:
      reader - YAML source
      Returns:
      the parsed manifest
      Throws:
      ManifestException - if the YAML has invalid structure or uses the legacy components: schema
    • migrateLegacySchemaIfNeeded

      public static boolean migrateLegacySchemaIfNeeded(Path manifestPath, Consumer<String> infoLog)
      Idempotently migrate a workspace.yaml file from the legacy components: schema to the new subprojects: schema.

      If the file does not contain any legacy markers this is a no-op (no file write, no log output). If any legacy markers are present the method rewrites in place:

      • ^components:subprojects:
      • ^component-types: block — removed entirely (terminated by the next top-level key at column 0 or EOF)
      • ^groups: block — removed entirely (same termination)
      • - component: (depends-on dash form) → - subproject:

      This is the entry point ws:align-publish calls before reading the manifest, so legacy workspaces auto-migrate on first align. Other callers get the hard-cut error from read(Path).

      Parameters:
      manifestPath - path to workspace.yaml
      infoLog - optional info-level log sink (nullable)
      Returns:
      true if the file was migrated, false if no legacy schema was present
      Throws:
      ManifestException - if the file cannot be read or written
    • migrate

      public static String migrate(String yaml)
      Apply legacy-schema rewrites to yaml text. Pure function — public for unit testing.
      Parameters:
      yaml - original workspace.yaml content
      Returns:
      migrated content (same as input if already on new schema)