Class PomModelAdapter

java.lang.Object
network.ike.plugin.scaffold.PomModelAdapter
All Implemented Interfaces:
ModelAdapter

public final class PomModelAdapter extends Object implements ModelAdapter
Model adapter for pom.xml via OpenRewrite's XML LST.

POM writes always go through OpenRewrite (not regex, not the Maven 4 model API) so formatting, comments, and whitespace survive round-trips.

Supported ensure subtree:

ensure:
  pluginManagement:
    - groupId: network.ike.tooling
      artifactId: ike-maven-plugin
      version: 127-SNAPSHOT

Semantics:

  • If the destination POM is missing, publish skips with an informational message — creating a POM from scratch is outside scaffold's responsibility.
  • For each ensured plugin, the adapter checks whether a matching <plugin> with the same groupId + artifactId exists anywhere under /project/build/pluginManagement/plugins. If absent it is appended (the whole pluginManagement scaffold is also created if missing). If present, the version is not changed — that is the job of ws:align-publish, not scaffold.
  • Each ensured plugin is recorded as a ManagedElement with path "/project/build/pluginManagement/plugins/plugin[groupId='G' and artifactId='A']".
  • Field Details

  • Constructor Details

    • PomModelAdapter

      public PomModelAdapter()
      Construct a stateless POM adapter. Instances are safe to share across planning calls; the underlying OpenRewrite parser is held in a static final field.
  • Method Details

    • modelName

      public String modelName()
      Description copied from interface: ModelAdapter
      Model name this adapter handles, matching ManifestEntry.model() (e.g. "maven-settings-4").
      Specified by:
      modelName in interface ModelAdapter
      Returns:
      the model name; never null
    • plan

      public ModelPlanResult plan(ManifestEntry entry, Path resolvedDest, byte[] currentContent, LockfileEntry priorEntry, String currentStandardsVersion)
      Description copied from interface: ModelAdapter
      Plan a single model-managed entry.
      Specified by:
      plan in interface ModelAdapter
      Parameters:
      entry - the manifest entry; must have ScaffoldTier.MODEL_MANAGED tier and model() equal to ModelAdapter.modelName()
      resolvedDest - absolute destination path (placeholders already expanded)
      currentContent - bytes currently on disk at resolvedDest, or null if no file exists
      priorEntry - lockfile entry from the last publish, or null if never applied
      currentStandardsVersion - the standards-version of the current manifest; stamped on newly-installed elements so drift can be reasoned about later
      Returns:
      a ModelPlanResult with both a TierAction and the element-level provenance for the lockfile