use of com.google.idea.blaze.base.command.buildresult.BepArtifactData in project intellij by bazelbuild.
the class BlazeBuildOutputs method updateOutputs.
/**
* Merges this {@link BlazeBuildOutputs} with a newer set of outputs.
*/
public BlazeBuildOutputs updateOutputs(BlazeBuildOutputs nextOutputs) {
// first combine common artifacts
Map<String, BepArtifactData> combined = new LinkedHashMap<>(artifacts);
for (Map.Entry<String, BepArtifactData> e : nextOutputs.artifacts.entrySet()) {
BepArtifactData a = e.getValue();
combined.compute(e.getKey(), (k, v) -> v == null ? a : v.update(a));
}
// data accordingly
for (String target : perTargetArtifacts.keySet()) {
if (!nextOutputs.perTargetArtifacts.containsKey(target)) {
continue;
}
Set<OutputArtifact> oldOutputs = perTargetArtifacts.get(target);
Set<OutputArtifact> newOutputs = nextOutputs.perTargetArtifacts.get(target);
// remove out of date target associations
for (OutputArtifact old : oldOutputs) {
if (newOutputs.contains(old)) {
continue;
}
// no longer output by this target; need to update target associations
BepArtifactData data = combined.get(old.getKey());
if (data != null) {
data = data.removeTargetAssociation(target);
}
if (data == null) {
combined.remove(old.getKey());
} else {
combined.put(old.getKey(), data);
}
}
}
return new BlazeBuildOutputs(BuildResult.combine(buildResult, nextOutputs.buildResult), combined, ImmutableList.<String>builder().addAll(buildIds).addAll(nextOutputs.buildIds).build());
}
Aggregations