improved a little BuildingIssue
This commit is contained in:
parent
09d0ce5f5a
commit
9373996f86
@ -2,6 +2,7 @@ package p.studio.compiler.messages;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import p.studio.utilities.logs.LogAggregator;
|
||||
|
||||
@Builder
|
||||
@Getter
|
||||
@ -9,4 +10,16 @@ public class BuildingIssue {
|
||||
private final boolean error;
|
||||
private final String message;
|
||||
private final Throwable exception;
|
||||
|
||||
public void print(LogAggregator logs) {
|
||||
if (error) {
|
||||
if (exception != null) {
|
||||
logs.error(message, exception);
|
||||
} else {
|
||||
logs.error(message);
|
||||
}
|
||||
} else {
|
||||
logs.warn(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,8 @@ import java.util.ArrayList;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class BuildingIssues extends ReadOnlyCollection<BuildingIssue> {
|
||||
private boolean hasErrors = false;
|
||||
|
||||
protected BuildingIssues() {
|
||||
super(new ArrayList<>());
|
||||
}
|
||||
@ -17,12 +19,19 @@ public class BuildingIssues extends ReadOnlyCollection<BuildingIssue> {
|
||||
public BuildingIssues add(final Consumer<BuildingIssue.BuildingIssueBuilder> consumer) {
|
||||
final var builder = BuildingIssue.builder();
|
||||
consumer.accept(builder);
|
||||
collection.add(builder.build());
|
||||
final var issue = builder.build();
|
||||
hasErrors |= issue.isError();
|
||||
collection.add(issue);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BuildingIssues addAll(final BuildingIssues issues) {
|
||||
public BuildingIssues add(final BuildingIssues issues) {
|
||||
hasErrors |= issues.hasErrors();
|
||||
collection.addAll(issues.collection);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean hasErrors() {
|
||||
return hasErrors;
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,18 +39,8 @@ public final class DependencyService {
|
||||
|
||||
for (final var dependencyPhase : phases) {
|
||||
final var issues = dependencyPhase.run(ctx);
|
||||
var error = false;
|
||||
if (ReadOnlyCollection.isNotEmpty(issues)) {
|
||||
for (final var issue : issues) {
|
||||
if (issue.isError()) {
|
||||
error = true;
|
||||
logs.using(log).error(issue.getMessage(), issue.getException());
|
||||
continue;
|
||||
}
|
||||
logs.using(log).warn(issue.getMessage());
|
||||
}
|
||||
}
|
||||
if (error) {
|
||||
issues.forEach(issue -> issue.print(logs.using(log)));
|
||||
if (issues.hasErrors()) {
|
||||
throw new BuildException("[DEPS]: issues found during dependency phase: " + dependencyPhase.getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ public final class WireProjectsPhase implements DependencyPhase {
|
||||
}
|
||||
if (sourceRootIssues.size() == projectInfo.getFrontendSpec().getSourceRoots().size()) {
|
||||
// no source roots were found at all
|
||||
issues.addAll(sourceRootIssues);
|
||||
issues.add(sourceRootIssues);
|
||||
}
|
||||
|
||||
return ProjectDescriptor
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user