small fixes
This commit is contained in:
parent
615c7abecd
commit
c74bbf03b4
@ -1,27 +1,18 @@
|
||||
package p.studio.compiler.models;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import p.studio.compiler.messages.BuilderPipelineConfig;
|
||||
import p.studio.utilities.logs.LogAggregator;
|
||||
|
||||
public class BuilderPipelineContext {
|
||||
@Getter
|
||||
private final BuilderPipelineConfig config;
|
||||
@Getter
|
||||
private final LogAggregator logs;
|
||||
@Getter
|
||||
@Setter
|
||||
private ResolvedWorkspace resolvedWorkspace;
|
||||
public final BuilderPipelineConfig config;
|
||||
|
||||
public ResolvedWorkspace resolvedWorkspace;
|
||||
|
||||
private BuilderPipelineContext(
|
||||
final BuilderPipelineConfig config,
|
||||
final LogAggregator logs) {
|
||||
final BuilderPipelineConfig config) {
|
||||
this.config = config;
|
||||
this.logs = logs;
|
||||
}
|
||||
|
||||
public static BuilderPipelineContext seed(BuilderPipelineConfig config, LogAggregator logAggregator) {
|
||||
return new BuilderPipelineContext(config, logAggregator);
|
||||
public static BuilderPipelineContext basedOn(BuilderPipelineConfig config) {
|
||||
return new BuilderPipelineContext(config);
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,10 +30,10 @@ public class BuilderPipelineService {
|
||||
public void run(
|
||||
final BuilderPipelineConfig config,
|
||||
final LogAggregator logs) {
|
||||
final var ctx = BuilderPipelineContext.seed(config, logs);
|
||||
final var ctx = BuilderPipelineContext.basedOn(config);
|
||||
|
||||
for (final var builderPipelineStage : stages) {
|
||||
final var issues = builderPipelineStage.run(ctx);
|
||||
final var issues = builderPipelineStage.run(ctx, logs);
|
||||
var error = false;
|
||||
if (ReadOnlyCollection.isNotEmpty(issues)) {
|
||||
for (final var issue : issues) {
|
||||
|
||||
@ -2,8 +2,9 @@ package p.studio.compiler.workspaces;
|
||||
|
||||
import p.studio.compiler.messages.BuildingIssue;
|
||||
import p.studio.compiler.models.BuilderPipelineContext;
|
||||
import p.studio.utilities.logs.LogAggregator;
|
||||
import p.studio.utilities.structures.ReadOnlyCollection;
|
||||
|
||||
public interface PipelineStage {
|
||||
ReadOnlyCollection<BuildingIssue> run(BuilderPipelineContext ctx);
|
||||
ReadOnlyCollection<BuildingIssue> run(BuilderPipelineContext ctx, LogAggregator logs);
|
||||
}
|
||||
|
||||
@ -5,33 +5,33 @@ 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;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
public class DepsPipelineStage implements PipelineStage {
|
||||
@Override
|
||||
public ReadOnlyCollection<BuildingIssue> run(final BuilderPipelineContext ctx) {
|
||||
public ReadOnlyCollection<BuildingIssue> run(final BuilderPipelineContext ctx, LogAggregator logs) {
|
||||
final Path rootCanonPath;
|
||||
try {
|
||||
rootCanonPath = Paths.get(ctx.getConfig().getRootProjectPath()).toRealPath();
|
||||
rootCanonPath = Paths.get(ctx.config.getRootProjectPath()).toRealPath();
|
||||
} catch (IOException e) {
|
||||
return ReadOnlyCollection.wrap(List.of(BuildingIssue
|
||||
return ReadOnlyCollection.with(BuildingIssue
|
||||
.builder()
|
||||
.error(true)
|
||||
.message("[DEPS]: rootProjectId directory no found: " + ctx.getConfig().getRootProjectPath())
|
||||
.build()));
|
||||
.message("[DEPS]: rootProjectId directory no found: " + ctx.config.getRootProjectPath())
|
||||
.build());
|
||||
}
|
||||
final var cfg = new DependencyConfig(false, rootCanonPath);
|
||||
final var resolvedWorkspace = DependencyService.INSTANCE.run(cfg, ctx.getLogs());
|
||||
final var resolvedWorkspace = DependencyService.INSTANCE.run(cfg, logs);
|
||||
for (final var pId : resolvedWorkspace.stack().projects()) {
|
||||
final var pd = resolvedWorkspace.graph().projectTable().get(pId);
|
||||
ctx.getLogs().info("Project [ " + pd.getName() + " ] read");
|
||||
logs.info("Project [ " + pd.getName() + " ] read");
|
||||
}
|
||||
ctx.setResolvedWorkspace(resolvedWorkspace);
|
||||
ctx.resolvedWorkspace = resolvedWorkspace;
|
||||
return ReadOnlyCollection.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ public final class DependencyContext {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public static DependencyContext seed(DependencyConfig config) {
|
||||
public static DependencyContext basedOn(DependencyConfig config) {
|
||||
return new DependencyContext(config);
|
||||
}
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ public final class DependencyService {
|
||||
public ResolvedWorkspace run(
|
||||
final DependencyConfig config,
|
||||
final LogAggregator logs) {
|
||||
final var ctx = DependencyContext.seed(config);
|
||||
final var ctx = DependencyContext.basedOn(config);
|
||||
|
||||
for (final var dependencyPhase : phases) {
|
||||
final var issues = dependencyPhase.run(ctx);
|
||||
|
||||
@ -90,7 +90,7 @@ public final class StackPhase implements DependencyPhase {
|
||||
.collect(joining("\n"));
|
||||
|
||||
var issue = BuildingIssue.builder().error(true).message(msg).build();
|
||||
return ReadOnlyCollection.wrap(List.of(issue));
|
||||
return ReadOnlyCollection.with(issue);
|
||||
}
|
||||
|
||||
ctx.stack = new BuildStack(ReadOnlyList.wrap(travesalOrder));
|
||||
|
||||
@ -5,11 +5,9 @@ import p.studio.compiler.models.DependencyContext;
|
||||
import p.studio.compiler.workspaces.DependencyPhase;
|
||||
import p.studio.utilities.structures.ReadOnlyCollection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class ValidatePhase implements DependencyPhase {
|
||||
@Override
|
||||
public ReadOnlyCollection<BuildingIssue> run(DependencyContext ctx) {
|
||||
public ReadOnlyCollection<BuildingIssue> run(final DependencyContext ctx) {
|
||||
// ensure rootProjectId is set
|
||||
if (ctx.rootProjectId == null) {
|
||||
final var issue = BuildingIssue
|
||||
@ -17,7 +15,7 @@ public final class ValidatePhase implements DependencyPhase {
|
||||
.error(true)
|
||||
.message("[DEPS]: rootProjectId ProjectId not set")
|
||||
.build();
|
||||
return ReadOnlyCollection.wrap(List.of(issue));
|
||||
return ReadOnlyCollection.with(issue);
|
||||
}
|
||||
|
||||
// ensure the dependenciesByProject matches the number of projectDescriptors
|
||||
@ -27,7 +25,7 @@ public final class ValidatePhase implements DependencyPhase {
|
||||
.error(true)
|
||||
.message("[DEPS]: internal error: dependenciesByProject and projectDescriptors size mismatch")
|
||||
.build();
|
||||
return ReadOnlyCollection.wrap(List.of(issue));
|
||||
return ReadOnlyCollection.with(issue);
|
||||
}
|
||||
|
||||
// ensure uniformity to version across the same projects (associated by name)
|
||||
@ -40,7 +38,7 @@ public final class ValidatePhase implements DependencyPhase {
|
||||
.error(true)
|
||||
.message("[DEPS]: inconsistent version for project: " + name + " (" + versions + ")")
|
||||
.build();
|
||||
return ReadOnlyCollection.wrap(List.of(issue));
|
||||
return ReadOnlyCollection.with(issue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
package p.studio.utilities.structures;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Spliterator;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class ReadOnlyCollection<T> implements Iterable<T> {
|
||||
@ -23,6 +21,13 @@ public class ReadOnlyCollection<T> implements Iterable<T> {
|
||||
return new ReadOnlyCollection<>(collection);
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public static <T> ReadOnlyCollection<T> with(final T... ts) {
|
||||
if (ts == null) return ReadOnlyCollection.empty();
|
||||
if (ts.length == 0) return ReadOnlyCollection.empty();
|
||||
return new ReadOnlyCollection<>(Stream.of(ts).toList());
|
||||
}
|
||||
|
||||
public static <T> boolean isEmpty(final ReadOnlyCollection<T> c) {
|
||||
if (c == null) return true;
|
||||
return c.isEmpty();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user