Class ReactorPom

java.lang.Object
network.ike.plugin.ws.ReactorPom

public final class ReactorPom extends Object
AST-aware editor for a workspace reactor POM's subproject membership, using OpenRewrite's XML LST so formatting, comments, and whitespace survive each edit (no regex on POMs).

Where PomRewriter owns release-path POM edits (dependency/parent/plugin/property versions), this class owns the workspace-reactor concern: the top-level <subprojects> block and the legacy with-<name> file-activated profiles that preceded it.

Two membership encodings

  • Modern — unconditional top-level <subprojects><subproject>name</subproject></subprojects>. ike-workspace-extension's SubprojectPruneTransformer (IKE-Network/ike-issues#460) prunes entries whose directory is absent at model-read time, so the declaration is safe even when a subproject has not been cloned yet.
  • Legacy — one <profile> per subproject, id with-<name>, <file><exists>-activated, declaring the member inside the profile's own <subprojects>. This is what ws:add historically generated; this class migrates it away.

All methods are pure: they take POM text and return POM text, leaving the input unchanged when there is nothing to do.

See Also:
  • Method Details

    • listSubprojects

      public static List<String> listSubprojects(String pomContent)
      List the reactor POM's top-level <subprojects> entries in declaration order.
      Parameters:
      pomContent - the raw POM text
      Returns:
      the subproject names; empty when there is no top-level <subprojects> block
    • listSubprojectProfiles

      public static List<ReactorPom.ProfileEntry> listSubprojectProfiles(String pomContent)
      List the reactor POM's legacy subproject-membership profiles — the <profile>s that declare one or more members inside their own <subprojects> block (the with-<name> pattern that ws:add generated before the #460 migration).

      A profile qualifies when it carries a non-empty <subprojects>; the with- id and <file><exists> activation are the convention but are not required for the match, so a hand-edited profile is recognized too.

      Parameters:
      pomContent - the raw POM text
      Returns:
      the qualifying profiles in declaration order; empty when none
    • setSubprojects

      public static String setSubprojects(String pomContent, List<String> names)
      Set the reactor POM's top-level <subprojects> block to exactly names, in the given order. Replaces an existing block in place (preserving its surrounding whitespace) or inserts a new one — before <profiles> when present, otherwise at the end of <project>.

      This single operation covers add (ws:add), remove (ws:remove), and full reconciliation against workspace.yaml: callers compute the target list and let this method materialize it idempotently.

      Parameters:
      pomContent - the raw POM text
      names - the exact subproject membership to declare
      Returns:
      updated POM text; unchanged when the block already matches
    • removeProfile

      public static String removeProfile(String pomContent, String profileId)
      Remove a single <profile> (matched by <id>) from the reactor POM, and drop the <profiles> block entirely if it becomes empty.
      Parameters:
      pomContent - the raw POM text
      profileId - the profile id to remove (e.g. with-komet)
      Returns:
      updated POM text; unchanged when no such profile exists