resolved workspace adjustments for topological order
This commit is contained in:
+8
-1
@@ -3,5 +3,12 @@ package p.studio.compiler.models;
|
||||
import p.studio.compiler.source.identifiers.ProjectId;
|
||||
import p.studio.utilities.structures.ReadOnlyList;
|
||||
|
||||
public record BuildStack(ReadOnlyList<ProjectId> projects) {
|
||||
public class BuildStack {
|
||||
public final ReadOnlyList<ProjectId> topologicalOrder;
|
||||
public final ReadOnlyList<ProjectId> reverseTopologicalOrder;
|
||||
|
||||
public BuildStack(ReadOnlyList<ProjectId> topologicalOrder) {
|
||||
this.topologicalOrder = topologicalOrder;
|
||||
this.reverseTopologicalOrder = topologicalOrder.invert();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -3,7 +3,6 @@ package p.studio.compiler.models;
|
||||
import p.studio.compiler.exceptions.BuildException;
|
||||
import p.studio.compiler.messages.DependencyConfig;
|
||||
import p.studio.compiler.source.identifiers.ProjectId;
|
||||
import p.studio.compiler.source.tables.FileTable;
|
||||
import p.studio.compiler.source.tables.ProjectTable;
|
||||
import p.studio.utilities.structures.ReadOnlyList;
|
||||
|
||||
@@ -28,7 +27,6 @@ public final class DependencyContext {
|
||||
|
||||
public ProjectId rootProjectId;
|
||||
public BuildStack stack;
|
||||
public FileTable fileTable;
|
||||
|
||||
private DependencyContext(DependencyConfig config) {
|
||||
this.config = config;
|
||||
@@ -56,7 +54,7 @@ public final class DependencyContext {
|
||||
}
|
||||
final var dependenciesByProject = buildDependenciesByProject();
|
||||
final var workspaceGraph = new WorkspaceGraph(projectTable, dependenciesByProject);
|
||||
return new ResolvedWorkspace(rootProjectId, workspaceGraph, stack, fileTable);
|
||||
return new ResolvedWorkspace(rootProjectId, workspaceGraph, stack);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+14
-3
@@ -1,11 +1,22 @@
|
||||
package p.studio.compiler.models;
|
||||
|
||||
import p.studio.compiler.source.identifiers.ProjectId;
|
||||
import p.studio.compiler.source.tables.FileTable;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public record ResolvedWorkspace(
|
||||
ProjectId projectId,
|
||||
WorkspaceGraph graph,
|
||||
BuildStack stack,
|
||||
FileTable fileTable) {
|
||||
BuildStack stack) {
|
||||
public ProjectDescriptor getMainProjectDescriptor() {
|
||||
return graph.getProjectDescriptor(projectId);
|
||||
}
|
||||
|
||||
public Stream<ProjectDescriptor> topologicalOrder() {
|
||||
return stack.topologicalOrder.stream().map(graph::getProjectDescriptor);
|
||||
}
|
||||
|
||||
public Stream<ProjectDescriptor> reverseTopologicalOrder() {
|
||||
return stack.reverseTopologicalOrder.stream().map(graph::getProjectDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-3
@@ -6,10 +6,12 @@ import p.studio.compiler.dtos.PrometeuManifestDTO;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public final class PrometeuManifestMapper {
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
public final class PrometeuManifestUtils {
|
||||
public static final PrometeuManifestUtils INSTANCE = new PrometeuManifestUtils();
|
||||
|
||||
public static PrometeuManifestDTO read(Path manifestPath) {
|
||||
private final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
public PrometeuManifestDTO read(Path manifestPath) {
|
||||
try {
|
||||
return mapper.readValue(manifestPath.toFile(), PrometeuManifestDTO.class);
|
||||
} catch (IOException e) {
|
||||
+2
-2
@@ -9,7 +9,7 @@ import p.studio.compiler.models.DependencyContext;
|
||||
import p.studio.compiler.models.ProjectInfo;
|
||||
import p.studio.compiler.models.ProjectInfoId;
|
||||
import p.studio.compiler.models.PrometeuManifest;
|
||||
import p.studio.compiler.utilities.PrometeuManifestMapper;
|
||||
import p.studio.compiler.utilities.PrometeuManifestUtils;
|
||||
import p.studio.compiler.workspaces.DependencyPhase;
|
||||
import p.studio.compiler.workspaces.DependencyReference;
|
||||
import p.studio.utilities.structures.ReadOnlyCollection;
|
||||
@@ -56,7 +56,7 @@ public class DiscoverPhase implements DependencyPhase {
|
||||
continue;
|
||||
}
|
||||
|
||||
final var prometeuManifestDTO = PrometeuManifestMapper.read(manifestPathCanon);
|
||||
final var prometeuManifestDTO = PrometeuManifestUtils.INSTANCE.read(manifestPathCanon);
|
||||
final var manifestMaybe = map(rootPathCanon, prometeuManifestDTO, issues);
|
||||
|
||||
if (manifestMaybe.isEmpty()) {
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ public final class ValidatePhase implements DependencyPhase {
|
||||
return ReadOnlyCollection.with(issue);
|
||||
}
|
||||
|
||||
// ensure uniformity to version across the same projects (associated by name)
|
||||
// ensure uniformity to version across the same projectIds (associated by name)
|
||||
for (final var entry : ctx.projectNameAndVersions.entrySet()) {
|
||||
final var name = entry.getKey();
|
||||
final var versions = entry.getValue();
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ public final class WireProjectsPhase implements DependencyPhase {
|
||||
return ReadOnlyCollection.wrap(issues);
|
||||
}
|
||||
|
||||
// since it is not ordered, we have to iterate it over again, but now associating dependencies with projects
|
||||
// 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));
|
||||
final var dependencies = new ArrayList<ProjectId>();
|
||||
|
||||
Reference in New Issue
Block a user