From 09d0ce5f5a9a135226d2a5151b16abc5e53a4b34 Mon Sep 17 00:00:00 2001 From: bQUARKz Date: Tue, 24 Feb 2026 18:42:43 +0000 Subject: [PATCH] improving logs by adding BuildingIssues structure --- .../compiler/workspaces/PipelineStage.java | 3 +- .../workspaces/stages/DepsPipelineStage.java | 20 +++--- .../compiler/messages/BuildingIssues.java | 28 ++++++++ .../compiler/models/ResolvedWorkspace.java | 8 +-- .../compiler/models/WorkspaceGraph.java | 4 +- .../compiler/workspaces/DependencyPhase.java | 5 +- .../workspaces/phases/DiscoverPhase.java | 69 +++++++------------ .../compiler/workspaces/phases/SeedPhase.java | 23 +++---- .../workspaces/phases/StackPhase.java | 18 ++--- .../workspaces/phases/ValidatePhase.java | 37 ++++------ .../workspaces/phases/WireProjectsPhase.java | 36 ++++------ 11 files changed, 113 insertions(+), 138 deletions(-) create mode 100644 prometeu-compiler/prometeu-compiler-core/src/main/java/p/studio/compiler/messages/BuildingIssues.java diff --git a/prometeu-compiler/prometeu-build-pipeline/src/main/java/p/studio/compiler/workspaces/PipelineStage.java b/prometeu-compiler/prometeu-build-pipeline/src/main/java/p/studio/compiler/workspaces/PipelineStage.java index 4d24f498..6dd2d255 100644 --- a/prometeu-compiler/prometeu-build-pipeline/src/main/java/p/studio/compiler/workspaces/PipelineStage.java +++ b/prometeu-compiler/prometeu-build-pipeline/src/main/java/p/studio/compiler/workspaces/PipelineStage.java @@ -1,10 +1,11 @@ package p.studio.compiler.workspaces; import p.studio.compiler.messages.BuildingIssue; +import p.studio.compiler.messages.BuildingIssues; import p.studio.compiler.models.BuilderPipelineContext; import p.studio.utilities.logs.LogAggregator; import p.studio.utilities.structures.ReadOnlyCollection; public interface PipelineStage { - ReadOnlyCollection run(BuilderPipelineContext ctx, LogAggregator logs); + BuildingIssues run(BuilderPipelineContext ctx, LogAggregator logs); } diff --git a/prometeu-compiler/prometeu-build-pipeline/src/main/java/p/studio/compiler/workspaces/stages/DepsPipelineStage.java b/prometeu-compiler/prometeu-build-pipeline/src/main/java/p/studio/compiler/workspaces/stages/DepsPipelineStage.java index 5bd9be8c..7abd1af6 100644 --- a/prometeu-compiler/prometeu-build-pipeline/src/main/java/p/studio/compiler/workspaces/stages/DepsPipelineStage.java +++ b/prometeu-compiler/prometeu-build-pipeline/src/main/java/p/studio/compiler/workspaces/stages/DepsPipelineStage.java @@ -1,12 +1,11 @@ package p.studio.compiler.workspaces.stages; -import p.studio.compiler.messages.BuildingIssue; +import p.studio.compiler.messages.BuildingIssues; import p.studio.compiler.messages.DependencyConfig; import p.studio.compiler.models.BuilderPipelineContext; import p.studio.compiler.workspaces.DependencyService; import p.studio.compiler.workspaces.PipelineStage; import p.studio.utilities.logs.LogAggregator; -import p.studio.utilities.structures.ReadOnlyCollection; import java.io.IOException; import java.nio.file.Path; @@ -14,21 +13,18 @@ import java.nio.file.Paths; public class DepsPipelineStage implements PipelineStage { @Override - public ReadOnlyCollection run(final BuilderPipelineContext ctx, LogAggregator logs) { + public BuildingIssues run(final BuilderPipelineContext ctx, LogAggregator logs) { final Path rootCanonPath; try { rootCanonPath = Paths.get(ctx.config.getRootProjectPath()).toRealPath(); } catch (IOException e) { - return ReadOnlyCollection.with(BuildingIssue - .builder() - .error(true) - .message("[BUILD]: root project directory no found: " + ctx.config.getRootProjectPath()) - .build()); + return BuildingIssues.empty() + .add(builder -> builder.error(true) + .message("[BUILD]: root project directory no found: " + ctx.config.getRootProjectPath())); } final var cfg = new DependencyConfig(false, rootCanonPath); - final var resolvedWorkspace = DependencyService.INSTANCE.run(cfg, logs); - resolvedWorkspace.topologicalOrder().forEach(pd -> logs.info("Project [ " + pd.getName() + " ] read")); - ctx.resolvedWorkspace = resolvedWorkspace; - return ReadOnlyCollection.empty(); + ctx.resolvedWorkspace = DependencyService.INSTANCE.run(cfg, logs); + ctx.resolvedWorkspace.topologicalOrder().forEach(pd -> logs.info("Project [ " + pd.getName() + " ] read")); + return BuildingIssues.empty(); } } diff --git a/prometeu-compiler/prometeu-compiler-core/src/main/java/p/studio/compiler/messages/BuildingIssues.java b/prometeu-compiler/prometeu-compiler-core/src/main/java/p/studio/compiler/messages/BuildingIssues.java new file mode 100644 index 00000000..e76ca262 --- /dev/null +++ b/prometeu-compiler/prometeu-compiler-core/src/main/java/p/studio/compiler/messages/BuildingIssues.java @@ -0,0 +1,28 @@ +package p.studio.compiler.messages; + +import p.studio.utilities.structures.ReadOnlyCollection; + +import java.util.ArrayList; +import java.util.function.Consumer; + +public class BuildingIssues extends ReadOnlyCollection { + protected BuildingIssues() { + super(new ArrayList<>()); + } + + public static BuildingIssues empty() { + return new BuildingIssues(); + } + + public BuildingIssues add(final Consumer consumer) { + final var builder = BuildingIssue.builder(); + consumer.accept(builder); + collection.add(builder.build()); + return this; + } + + public BuildingIssues addAll(final BuildingIssues issues) { + collection.addAll(issues.collection); + return this; + } +} diff --git a/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/models/ResolvedWorkspace.java b/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/models/ResolvedWorkspace.java index 1728da41..d56831de 100644 --- a/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/models/ResolvedWorkspace.java +++ b/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/models/ResolvedWorkspace.java @@ -8,15 +8,15 @@ public record ResolvedWorkspace( ProjectId projectId, WorkspaceGraph graph, BuildStack stack) { - public ProjectDescriptor getMainProjectDescriptor() { - return graph.getProjectDescriptor(projectId); + public ProjectDescriptor mainProject() { + return graph.projectDescriptor(projectId); } public Stream topologicalOrder() { - return stack.topologicalOrder.stream().map(graph::getProjectDescriptor); + return stack.topologicalOrder.stream().map(graph::projectDescriptor); } public Stream reverseTopologicalOrder() { - return stack.reverseTopologicalOrder.stream().map(graph::getProjectDescriptor); + return stack.reverseTopologicalOrder.stream().map(graph::projectDescriptor); } } diff --git a/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/models/WorkspaceGraph.java b/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/models/WorkspaceGraph.java index f8556426..0405ec4e 100644 --- a/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/models/WorkspaceGraph.java +++ b/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/models/WorkspaceGraph.java @@ -8,11 +8,11 @@ public record WorkspaceGraph( ProjectTable projectTable, ReadOnlyList> dependenciesByProjectId) { - public ProjectDescriptor getProjectDescriptor(final ProjectId projectId) { + public ProjectDescriptor projectDescriptor(final ProjectId projectId) { return projectTable.get(projectId); } - public ReadOnlyList getDependencies(final ProjectId projectId) { + public ReadOnlyList dependencies(final ProjectId projectId) { return dependenciesByProjectId.get(projectId.getIndex()); } } diff --git a/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/DependencyPhase.java b/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/DependencyPhase.java index 2c003133..846ed078 100644 --- a/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/DependencyPhase.java +++ b/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/DependencyPhase.java @@ -1,9 +1,8 @@ package p.studio.compiler.workspaces; -import p.studio.compiler.messages.BuildingIssue; +import p.studio.compiler.messages.BuildingIssues; import p.studio.compiler.models.DependencyContext; -import p.studio.utilities.structures.ReadOnlyCollection; public interface DependencyPhase { - ReadOnlyCollection run(DependencyContext state); + BuildingIssues run(DependencyContext state); } diff --git a/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/phases/DiscoverPhase.java b/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/phases/DiscoverPhase.java index 74c07ef5..50b8340e 100644 --- a/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/phases/DiscoverPhase.java +++ b/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/phases/DiscoverPhase.java @@ -4,7 +4,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import p.studio.compiler.FrontendRegistryService; import p.studio.compiler.dtos.PrometeuManifestDTO; -import p.studio.compiler.messages.BuildingIssue; +import p.studio.compiler.messages.BuildingIssues; import p.studio.compiler.models.DependencyContext; import p.studio.compiler.models.ProjectInfo; import p.studio.compiler.models.ProjectInfoId; @@ -23,9 +23,9 @@ import java.util.*; public class DiscoverPhase implements DependencyPhase { @Override - public ReadOnlyCollection run(final DependencyContext ctx) { + public BuildingIssues run(final DependencyContext ctx) { final Map projectIndexByDirectory = new HashMap<>(); - final List issues = new ArrayList<>(); + final BuildingIssues issues = BuildingIssues.empty(); while (!ctx.pending.isEmpty()) { final var rootPathCanon = ctx.pending.pollFirst(); @@ -37,22 +37,16 @@ public class DiscoverPhase implements DependencyPhase { try { manifestPathCanon = rootPathCanon.resolve("prometeu.json").toRealPath(); } catch (IOException e) { - final var issue = BuildingIssue - .builder() + issues.add(builder -> builder .error(true) .message("[DEPS]: manifest canonPath does not exist: " + rootPathCanon) - .exception(e) - .build(); - issues.add(issue); + .exception(e)); continue; } if (!Files.exists(manifestPathCanon) || !Files.isRegularFile(manifestPathCanon)) { - final var issue = BuildingIssue - .builder() + issues.add(builder -> builder .error(true) - .message("[DEPS]: manifest not found: expected a file " + manifestPathCanon) - .build(); - issues.add(issue); + .message("[DEPS]: manifest not found: expected a file " + manifestPathCanon)); continue; } @@ -67,12 +61,9 @@ public class DiscoverPhase implements DependencyPhase { final var frontendSpec = FrontendRegistryService.getFrontendSpec(manifest.language()); if (frontendSpec.isEmpty()) { - final var issue = BuildingIssue - .builder() + issues.add(builder -> builder .error(true) - .message("[DEPS]: unknown language " + manifest.language() + " for project " + manifest.name()) - .build(); - issues.add(issue); + .message("[DEPS]: unknown language " + manifest.language() + " for project " + manifest.name())); continue; } @@ -91,39 +82,33 @@ public class DiscoverPhase implements DependencyPhase { ctx.projectNameAndVersions.computeIfAbsent(manifest.name(), ignore -> new HashSet<>()).add(manifest.version()); } - return ReadOnlyCollection.wrap(issues); + return issues; } public static Optional map( final Path rootPath, final PrometeuManifestDTO dto, - final List buildingIssues) { + final BuildingIssues issues) { if (StringUtils.isBlank(dto.name())) { - final var issue = BuildingIssue - .builder() + issues.add(builder -> builder .error(true) - .message("[DEPS]: manifest missing 'name': " + rootPath) - .build(); - buildingIssues.add(issue); + .message("[DEPS]: manifest missing 'name': " + rootPath)); } if (StringUtils.isBlank(dto.version())) { - final var issue = BuildingIssue - .builder() + issues.add(builder -> builder .error(true) - .message("[DEPS]: manifest missing 'version': " + rootPath) - .build(); - buildingIssues.add(issue); + .message("[DEPS]: manifest missing 'version': " + rootPath)); } final var language = StringUtils.isBlank(dto.language()) ? FrontendRegistryService.getDefaultFrontendSpec().getLanguageId() : dto.language(); - final var dependencies = resolveDependencies(rootPath, dto.dependencies(), buildingIssues); + final var dependencies = resolveDependencies(rootPath, dto.dependencies(), issues); - if (CollectionUtils.isNotEmpty(buildingIssues)) { + if (ReadOnlyCollection.isNotEmpty(issues)) { return Optional.empty(); } @@ -133,7 +118,7 @@ public class DiscoverPhase implements DependencyPhase { private static List resolveDependencies( final Path rootProjectCanonPath, final List dependencies, - final List buildingIssues) { + final BuildingIssues issues) { if (CollectionUtils.isEmpty(dependencies)) { return List.of(); } @@ -146,24 +131,16 @@ public class DiscoverPhase implements DependencyPhase { final Path dependencyPathCanon = rootProjectCanonPath.resolve(local.path()).toRealPath(); deps.add(new DependencyReference(dependencyPathCanon)); } catch (IOException e) { - final var issue = BuildingIssue - .builder() + issues.add(builder -> builder .error(true) .message("[DEPS]: failed to canonicalize dependency path: " + local.path() + " from (" + rootProjectCanonPath + ")") - .exception(e) - .build(); - buildingIssues.add(issue); + .exception(e)); } } - case PrometeuManifestDTO.DependencyDeclaration.Git git -> { - final var issue = BuildingIssue - .builder() - .error(true) - .message("[DEPS]: git dependencies are not supported yet: " + git.url() + " from (" + rootProjectCanonPath + ")") - .build(); - buildingIssues.add(issue); - } + case PrometeuManifestDTO.DependencyDeclaration.Git git -> issues.add(builder -> builder + .error(true) + .message("[DEPS]: git dependencies are not supported yet: " + git.url() + " from (" + rootProjectCanonPath + ")")); default -> { } diff --git a/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/phases/SeedPhase.java b/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/phases/SeedPhase.java index b1377cf3..b999c6d5 100644 --- a/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/phases/SeedPhase.java +++ b/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/phases/SeedPhase.java @@ -1,29 +1,26 @@ package p.studio.compiler.workspaces.phases; -import p.studio.compiler.messages.BuildingIssue; -import p.studio.compiler.workspaces.DependencyPhase; +import p.studio.compiler.messages.BuildingIssues; import p.studio.compiler.models.DependencyContext; -import p.studio.utilities.structures.ReadOnlyCollection; +import p.studio.compiler.workspaces.DependencyPhase; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; public final class SeedPhase implements DependencyPhase { @Override - public ReadOnlyCollection run(final DependencyContext ctx) { - final List issues = new ArrayList<>(); + public BuildingIssues run(final DependencyContext ctx) { try { ctx.mainProjectRootPathCanon = ctx.config().cacheDir().toRealPath(); } catch (IOException e) { - final var issue = BuildingIssue - .builder() - .message("[DEPS]: failed to canonicalize rootProjectId directory: " + ctx.config().cacheDir()) - .build(); - issues.add(issue); + return BuildingIssues.empty() + .add(builder -> builder + .error(true) + .message("[DEPS]: failed to canonicalize rootProjectId directory: " + ctx.config().cacheDir()) + .exception(e)); } + ctx.pending.add(ctx.mainProjectRootPathCanon); - return ReadOnlyCollection.wrap(issues); + return BuildingIssues.empty(); } } diff --git a/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/phases/StackPhase.java b/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/phases/StackPhase.java index 53edc874..47439e40 100644 --- a/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/phases/StackPhase.java +++ b/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/phases/StackPhase.java @@ -1,12 +1,11 @@ package p.studio.compiler.workspaces.phases; +import p.studio.compiler.messages.BuildingIssues; import p.studio.compiler.models.BuildStack; -import p.studio.compiler.messages.BuildingIssue; +import p.studio.compiler.models.DependencyContext; import p.studio.compiler.models.ProjectInfoId; import p.studio.compiler.source.identifiers.ProjectId; -import p.studio.compiler.models.DependencyContext; import p.studio.compiler.workspaces.DependencyPhase; -import p.studio.utilities.structures.ReadOnlyCollection; import p.studio.utilities.structures.ReadOnlyList; import java.util.ArrayDeque; @@ -21,7 +20,7 @@ public final class StackPhase implements DependencyPhase { * Implements topological sort; detects dependency cycles; sets build stack */ @Override - public ReadOnlyCollection run(final DependencyContext ctx) { + public BuildingIssues run(final DependencyContext ctx) { final int n = ctx.projectTable.size(); final int[] indeg = new int[n]; for (int from = 0; from < n; from++) { @@ -58,16 +57,11 @@ public final class StackPhase implements DependencyPhase { final List> cycles = new ArrayList<>(); for (var scc : sccs) { if (scc.size() > 1) { -// final var cycle = scc -// .stream() -// .map(i -> ctx.projectDescriptors.get(i).getProjectId()) -// .toList(); final var cycle = scc.stream().map(ProjectId::new).toList(); cycles.add(cycle); } else { // size==1: cycle only if self-loop exists final var u = scc.getFirst(); -// final var projectId = ctx.projectDescriptors.get(u).getProjectId(); final var projectId = new ProjectId(u); boolean selfLoop = false; for (final var pu : ctx.dependenciesByProject.get(u)) { @@ -89,13 +83,13 @@ public final class StackPhase implements DependencyPhase { ) .collect(joining("\n")); - var issue = BuildingIssue.builder().error(true).message(msg).build(); - return ReadOnlyCollection.with(issue); + return BuildingIssues.empty() + .add(builder -> builder.error(true).message(msg)); } ctx.stack = new BuildStack(ReadOnlyList.wrap(travesalOrder)); - return ReadOnlyCollection.empty(); + return BuildingIssues.empty(); } static final class TarjanScc { diff --git a/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/phases/ValidatePhase.java b/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/phases/ValidatePhase.java index 8ceb967b..dfbbc31e 100644 --- a/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/phases/ValidatePhase.java +++ b/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/phases/ValidatePhase.java @@ -1,31 +1,26 @@ package p.studio.compiler.workspaces.phases; -import p.studio.compiler.messages.BuildingIssue; +import p.studio.compiler.messages.BuildingIssues; import p.studio.compiler.models.DependencyContext; import p.studio.compiler.workspaces.DependencyPhase; -import p.studio.utilities.structures.ReadOnlyCollection; public final class ValidatePhase implements DependencyPhase { @Override - public ReadOnlyCollection run(final DependencyContext ctx) { + public BuildingIssues run(final DependencyContext ctx) { // ensure rootProjectId is set if (ctx.rootProjectId == null) { - final var issue = BuildingIssue - .builder() - .error(true) - .message("[DEPS]: rootProjectId ProjectId not set") - .build(); - return ReadOnlyCollection.with(issue); + return BuildingIssues.empty() + .add(builder -> builder + .error(true) + .message("[DEPS]: rootProjectId ProjectId not set")); } // ensure the dependenciesByProject matches the number of projectDescriptors if (ctx.dependenciesByProject.size() != ctx.projectTable.size()) { - final var issue = BuildingIssue - .builder() - .error(true) - .message("[DEPS]: internal error: dependenciesByProject and projectDescriptors size mismatch") - .build(); - return ReadOnlyCollection.with(issue); + return BuildingIssues.empty() + .add(builder -> builder + .error(true) + .message("[DEPS]: internal error: dependenciesByProject and projectDescriptors size mismatch")); } // ensure uniformity to version across the same projectIds (associated by name) @@ -33,17 +28,15 @@ public final class ValidatePhase implements DependencyPhase { final var name = entry.getKey(); final var versions = entry.getValue(); if (versions.size() > 1) { - final var issue = BuildingIssue - .builder() - .error(true) - .message("[DEPS]: inconsistent version for project: " + name + " (" + versions + ")") - .build(); - return ReadOnlyCollection.with(issue); + return BuildingIssues.empty() + .add(builder -> builder + .error(true) + .message("[DEPS]: inconsistent version for project: " + name + " (" + versions + ")")); } } // run check over source policy (if any) from here (FrontedSpec) - return ReadOnlyCollection.empty(); + return BuildingIssues.empty(); } } diff --git a/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/phases/WireProjectsPhase.java b/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/phases/WireProjectsPhase.java index b097edb7..cb02cf94 100644 --- a/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/phases/WireProjectsPhase.java +++ b/prometeu-compiler/prometeu-deps/src/main/java/p/studio/compiler/workspaces/phases/WireProjectsPhase.java @@ -1,13 +1,12 @@ package p.studio.compiler.workspaces.phases; -import p.studio.compiler.messages.BuildingIssue; +import p.studio.compiler.messages.BuildingIssues; import p.studio.compiler.models.DependencyContext; import p.studio.compiler.models.ProjectDescriptor; import p.studio.compiler.models.ProjectInfo; import p.studio.compiler.models.ProjectInfoId; import p.studio.compiler.source.identifiers.ProjectId; import p.studio.compiler.workspaces.DependencyPhase; -import p.studio.utilities.structures.ReadOnlyCollection; import p.studio.utilities.structures.ReadOnlyList; import java.io.IOException; @@ -17,14 +16,14 @@ import java.util.List; public final class WireProjectsPhase implements DependencyPhase { @Override - public ReadOnlyCollection run(final DependencyContext ctx) { + public BuildingIssues run(final DependencyContext ctx) { // to start all over again, we will re-populate the project nodes and dependenciesByProjectId based on the project infos ctx.rootProjectId = null; ctx.projectIds.clear(); ctx.projectTable.clear(); ctx.dependenciesByProject.clear(); - final List issues = new ArrayList<>(); + final BuildingIssues issues = BuildingIssues.empty(); for (int index = 0; index < ctx.projectInfoTable.size(); index++) { final var projectInfo = ctx.projectInfoTable.get(new ProjectInfoId(index)); @@ -35,14 +34,11 @@ public final class WireProjectsPhase implements DependencyPhase { final var rootProjectId = ctx.projectTable.optionalId(ctx.mainProjectRootPathCanon); if (rootProjectId.isEmpty()) { - final var issue = BuildingIssue - .builder() - .message("[DEPS]: rootProjectId project dir " + ctx.mainProjectRootPathCanon + " was not discovered/materialized") - .build(); - issues.add(issue); - return ReadOnlyCollection.wrap(issues); + return issues.add(builder -> builder + .message("[DEPS]: rootProjectId project dir " + ctx.mainProjectRootPathCanon + " was not discovered/materialized")); } + // since it is not ordered, we have to iterate it over again, but now associating dependencies with projectIds for (int i = 0; i < ctx.projectInfoTable.size(); i++) { final var projectInfo = ctx.projectInfoTable.get(new ProjectInfoId(i)); @@ -51,12 +47,9 @@ public final class WireProjectsPhase implements DependencyPhase { final var dependencyCanonPath = dependency.canonPath(); final var projectId = ctx.projectTable.optionalId(dependencyCanonPath); if (projectId.isEmpty()) { - final var issue = BuildingIssue - .builder() + issues.add(builder -> builder .error(true) - .message("[DEPS]: dependency not found: " + dependencyCanonPath) - .build(); - issues.add(issue); + .message("[DEPS]: dependency not found: " + dependencyCanonPath)); continue; } dependencies.add(projectId.get()); @@ -66,13 +59,13 @@ public final class WireProjectsPhase implements DependencyPhase { ctx.rootProjectId = rootProjectId.get(); - return ReadOnlyCollection.wrap(issues); + return issues; } private static ProjectDescriptor buildProjectDescriptor( final ProjectInfo projectInfo, - final List issues) { - final List sourceRootIssues = new ArrayList<>(); + final BuildingIssues issues) { + final BuildingIssues sourceRootIssues = BuildingIssues.empty(); final List sourceRoots = new ArrayList<>(); for (final var sourceRoot : projectInfo.getFrontendSpec().getSourceRoots()) { final var sourceRootPath = projectInfo.rootDirectory.resolve(sourceRoot); @@ -80,13 +73,10 @@ public final class WireProjectsPhase implements DependencyPhase { final var sourceRootPathCanon = sourceRootPath.toRealPath(); sourceRoots.add(sourceRootPathCanon); } catch (IOException e) { - final var issue = BuildingIssue - .builder() + sourceRootIssues.add(builder -> builder .error(true) .message("[DEPS]: source project canonPath does not exist: " + sourceRootPath + " (from " + projectInfo.rootDirectory + ")") - .exception(e) - .build(); - sourceRootIssues.add(issue); + .exception(e)); } } if (sourceRootIssues.size() == projectInfo.getFrontendSpec().getSourceRoots().size()) {