packer (WIP)

This commit is contained in:
2026-03-24 13:42:54 +00:00
parent c5b10907c9
commit 83546149e4
14 changed files with 397 additions and 0 deletions
@@ -0,0 +1,22 @@
package p.packer.dtos;
import java.nio.file.Path;
import java.util.Objects;
public record PackerEmittedArtifactDTO(
String label,
Path path,
boolean canonical,
long sizeBytes) {
public PackerEmittedArtifactDTO {
label = Objects.requireNonNull(label, "label").trim();
path = Objects.requireNonNull(path, "path").toAbsolutePath().normalize();
if (label.isBlank()) {
throw new IllegalArgumentException("label must not be blank");
}
if (sizeBytes < 0L) {
throw new IllegalArgumentException("sizeBytes must not be negative");
}
}
}
@@ -0,0 +1,25 @@
package p.packer.dtos;
import java.util.List;
import java.util.Objects;
public record PackerPackExecutionSummaryDTO(
String canonicalArtifactName,
int packedAssetCount,
long elapsedMillis,
List<PackerEmittedArtifactDTO> emittedArtifacts) {
public PackerPackExecutionSummaryDTO {
canonicalArtifactName = Objects.requireNonNull(canonicalArtifactName, "canonicalArtifactName").trim();
emittedArtifacts = List.copyOf(Objects.requireNonNull(emittedArtifacts, "emittedArtifacts"));
if (canonicalArtifactName.isBlank()) {
throw new IllegalArgumentException("canonicalArtifactName must not be blank");
}
if (packedAssetCount < 0) {
throw new IllegalArgumentException("packedAssetCount must not be negative");
}
if (elapsedMillis < 0L) {
throw new IllegalArgumentException("elapsedMillis must not be negative");
}
}
}
@@ -0,0 +1,22 @@
package p.packer.dtos;
import java.util.Objects;
public record PackerPackSummaryDTO(
int includedRegisteredAssetCount,
int outsideBuildSetAssetCount,
String canonicalArtifactName) {
public PackerPackSummaryDTO {
if (includedRegisteredAssetCount < 0) {
throw new IllegalArgumentException("includedRegisteredAssetCount must not be negative");
}
if (outsideBuildSetAssetCount < 0) {
throw new IllegalArgumentException("outsideBuildSetAssetCount must not be negative");
}
canonicalArtifactName = Objects.requireNonNull(canonicalArtifactName, "canonicalArtifactName").trim();
if (canonicalArtifactName.isBlank()) {
throw new IllegalArgumentException("canonicalArtifactName must not be blank");
}
}
}
@@ -0,0 +1,18 @@
package p.packer.dtos;
import java.util.List;
import java.util.Objects;
public record PackerPackValidationAssetDTO(
PackerAssetSummaryDTO asset,
boolean blocked,
List<PackerDiagnosticDTO> diagnostics) {
public PackerPackValidationAssetDTO {
Objects.requireNonNull(asset, "asset");
diagnostics = List.copyOf(Objects.requireNonNull(diagnostics, "diagnostics"));
if (blocked && diagnostics.stream().noneMatch(PackerDiagnosticDTO::blocking)) {
throw new IllegalArgumentException("blocked validation asset must include at least one blocking diagnostic");
}
}
}
@@ -0,0 +1,26 @@
package p.packer.dtos;
public record PackerPackValidationSummaryDTO(
int totalAssetsInScope,
int validAssetCount,
int blockedAssetCount,
boolean canPack) {
public PackerPackValidationSummaryDTO {
if (totalAssetsInScope < 0) {
throw new IllegalArgumentException("totalAssetsInScope must not be negative");
}
if (validAssetCount < 0) {
throw new IllegalArgumentException("validAssetCount must not be negative");
}
if (blockedAssetCount < 0) {
throw new IllegalArgumentException("blockedAssetCount must not be negative");
}
if (validAssetCount + blockedAssetCount > totalAssetsInScope) {
throw new IllegalArgumentException("validAssetCount + blockedAssetCount must not exceed totalAssetsInScope");
}
if (canPack && blockedAssetCount > 0) {
throw new IllegalArgumentException("canPack must be false when blockedAssetCount is greater than zero");
}
}
}