Class SubprojectResolver

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

public final class SubprojectResolver extends Object
Resolves a Maven coordinate (groupId:artifactId) to the workspace subproject that produces it.

This is the single place that encodes the rule a POM coordinate maps to a workspace subproject only on a full groupId and artifactId match against that subproject's published artifact set — never by groupId alone. A coordinate that matches no subproject is external and resolves to Optional.empty(); callers must leave external coordinates untouched (no manifest parent:/depends-on edge, no version rewrite).

groupId-alone matching mis-associates whenever two subprojects (or a subproject and an external artifact) share a groupId — e.g. network.ike.platform is shared by the external ike-parent and the subproject ike-commonmark-attributes (IKE-Network/ike-issues#565), and dev.ikm.komet is shared by the komet and komet-bom subprojects (#566). Routing every coordinate→subproject lookup through this resolver closes that class of defect; it mirrors the GA-matching rule the parent-version machinery already applies (#241).

Built once by scanning every cloned subproject's published artifacts (regex-based, via PublishedArtifactSet). Uncloned subprojects (no pom.xml on disk) contribute nothing — they have no scannable POM, so their coordinates resolve as external until cloned.

Thread-confined: build one per operation; the backing index is an immutable snapshot of disk state at scan(Path, Manifest) time.

  • Method Details

    • scan

      public static SubprojectResolver scan(Path wsDir, network.ike.workspace.Manifest manifest) throws IOException
      Build a resolver by scanning each manifest subproject's published artifact set.

      When two subprojects pathologically publish the same coordinate, the first in manifest iteration order wins (matching the first-match behaviour of the call sites this replaces).

      Parameters:
      wsDir - workspace root directory
      manifest - parsed workspace manifest
      Returns:
      a resolver over the manifest's cloned subprojects
      Throws:
      IOException - if a subproject POM cannot be read
    • subprojectForCoordinate

      public Optional<String> subprojectForCoordinate(String groupId, String artifactId)
      The workspace subproject that publishes the given coordinate, or empty when the coordinate is external (produced by no subproject, or either coordinate is null).
      Parameters:
      groupId - Maven groupId
      artifactId - Maven artifactId
      Returns:
      the producing subproject name, or empty when external