Record Class AdocManifest

java.lang.Object
java.lang.Record
network.ike.plugin.adoc.AdocManifest
Record Components:
groupId - the owning group, from coordinates
artifactId - the artifact, from coordinates
packages - the packages shipped, in manifest order
registry - the registry path relative to the root, or null when the manifest names none

public record AdocManifest(String groupId, String artifactId, List<AdocPackage> packages, String registry) extends Record
A library's manifest: its coordinates and the packages it ships, generated by the build from the pom and the tree and shipped at META-INF/ike/<group>/<artifact>/manifest.yaml (IKE-Network/ike-issues#1341). The union goal reads it to know what a zip puts in the union and to refuse two libraries that ship one package.
coordinates: network.ike.lab:unlv-topics
packages:
  - name: network.ike.lab/aip
    kind: topics
  - name: network.ike.lab/unlv
    kind: library
registry: META-INF/ike/network.ike.lab/unlv-topics/topic-registry.yaml

A module of the same reactor has no zip at generate-sources, so its manifest is derived from its source tree with fromSourceTree(AdocCoordinates, Path): every directory under the root whose name has a dot is a group, a group directory that holds files directly is one package, and otherwise each directory under it is one. The manifest the doc plugin generates is the one a zip ships; the derived one is for linking the member into the union.

  • Field Details

    • FILE_NAME

      public static final String FILE_NAME
      The manifest's file name inside the library's META-INF area.
      See Also:
  • Constructor Details

    • AdocManifest

      public AdocManifest(String groupId, String artifactId, List<AdocPackage> packages, String registry)
      Checks the parts and copies the package list.
      Parameters:
      groupId - the group
      artifactId - the artifact
      packages - the packages
      registry - the registry path, or null
  • Method Details

    • ga

      public String ga()
      The group and artifact as the manifest writes them, group:artifact.
      Returns:
      the coordinates without a version
    • parse

      public static AdocManifest parse(String yaml, String source)
      Parses a manifest.
      Parameters:
      yaml - the manifest text
      source - what the text came from, for the message of a refusal
      Returns:
      the manifest
      Throws:
      org.apache.maven.api.plugin.MojoException - if the text has no coordinates or no package list
    • readFromZip

      public static Optional<AdocManifest> readFromZip(Path zip, AdocCoordinates coordinates)
      Reads a library's manifest from its zip, at the entry its coordinates name.
      Parameters:
      zip - the library's adoc zip
      coordinates - the library's coordinates
      Returns:
      the manifest, or empty when the zip ships none, which marks a legacy library
      Throws:
      org.apache.maven.api.plugin.MojoException - if the zip cannot be read or the manifest cannot be parsed
    • read

      public static AdocManifest read(Path file)
      Reads a manifest file from a directory tree, such as the union.
      Parameters:
      file - the manifest file
      Returns:
      the manifest
      Throws:
      org.apache.maven.api.plugin.MojoException - if the file cannot be read or parsed
    • fromSourceTree

      public static AdocManifest fromSourceTree(AdocCoordinates coordinates, Path root)
      Derives the manifest of a reactor member from its source tree. A directory under the root is a group when its name has a dot and does not start with one. A group directory that holds a file directly is one package, as network.ike.kompendium.anf is; otherwise each directory under it is a package. A package is of kind "topics" when any .adoc file in it declares a :topic-id:, else "library". A root without any group directory, the legacy topics/ layout among them, yields no packages.
      Parameters:
      coordinates - the member's coordinates
      root - the member's AsciiDoc source root
      Returns:
      the derived manifest, with no registry path
      Throws:
      org.apache.maven.api.plugin.MojoException - if the tree cannot be read
    • packageOwning

      public Optional<AdocPackage> packageOwning(String path)
      The package this manifest ships that holds a path, the longest one when a group package and a domain package both match.
      Parameters:
      path - a path relative to the root, with forward slashes
      Returns:
      the owning package, or empty when none ships it
    • toYaml

      public String toYaml()
      Writes the manifest as YAML, deterministically, so an unchanged manifest rewrites to the same bytes.
      Returns:
      the YAML text
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • groupId

      public String groupId()
      Returns the value of the groupId record component.
      Returns:
      the value of the groupId record component
    • artifactId

      public String artifactId()
      Returns the value of the artifactId record component.
      Returns:
      the value of the artifactId record component
    • packages

      public List<AdocPackage> packages()
      Returns the value of the packages record component.
      Returns:
      the value of the packages record component
    • registry

      public String registry()
      Returns the value of the registry record component.
      Returns:
      the value of the registry record component