Class CpeArtifactsEncoder

java.lang.Object
io.quarkus.sbom.CpeArtifactsEncoder

public final class CpeArtifactsEncoder extends Object
Encodes and decodes the cpe-artifacts platform property.

The property records, for each supported runtime extension artifact of a platform member, the set of artifacts that a consumer (a Quarkus build step) should attribute to that member's CPE. The data is a map keyed by the runtime extension artifact, so a consumer can look up the runtime artifacts flagged in the ApplicationModel directly, without having to map them to their deployment counterparts itself. The value of each entry is the extension's deployment artifact followed by the artifacts of its resolved deployment dependency closure (aligned to the versions the platform ships).

Serialized format

The same coordinates recur heavily across entries (deployment closures overlap between extensions), and even distinct coordinates share groupIds, versions and artifactId prefixes. The map is serialized in two sections separated by a "--" line:
  1. a dictionary of every distinct coordinate, grouped so shared parts are written once;
  2. the entries: one line per runtime extension as <runtime-index>[<delta>,<delta>,...], where the runtime index and the (delta-encoded) dependency indices are base-36 references into the dictionary.

Dictionary section

Coordinates are grouped by groupId; within a groupId they are grouped by version. Each line is self-identifying by its first character:
  • @groupId — starts a group; the very next line is that group's common artifactId prefix (possibly empty), applied to every artifact line in the group;
  • =version — starts a version sub-block within the current group;
  • anything else — an artifact line: the artifactId with the group prefix stripped, optionally followed by :classifier and/or :type. Trailing defaults (empty classifier, jar type) are omitted, so a plain artifactId means an empty-classifier jar. An empty line means the artifactId equals the group prefix exactly.
Artifact lines take dictionary indices sequentially in the order they appear; the @/prefix/= lines consume no index. The prefix line is positional (always present immediately after @groupId), so no sentinel character is needed for it and empty lines are unambiguously artifact lines.

Removing the long-range repetition this way (which deflate's 32 KB window cannot reach) and delta-encoding the ascending dependency indices shrinks a real platform member's encoded value by roughly a fifth beyond a naive dictionary.

The output is deterministic and therefore reproducible: the dictionary is sorted by (groupId, version, artifactId, classifier, type), so index assignment depends only on content (not on the input map's iteration order); entries are ordered by their runtime key's dictionary index; and dependency indices are emitted in ascending order. The serialized text is then deflate-compressed and Base64-encoded to keep the property value compact. Byte-identical output across builds additionally assumes a consistent JDK/zlib (the release toolchain), as with any deflate-based artifact.