Search in sources :

Example 1 with BepArtifactData

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());
}
Also used : OutputArtifact(com.google.idea.blaze.base.command.buildresult.OutputArtifact) LinkedHashMap(java.util.LinkedHashMap) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) BepArtifactData(com.google.idea.blaze.base.command.buildresult.BepArtifactData) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)1 BepArtifactData (com.google.idea.blaze.base.command.buildresult.BepArtifactData)1 OutputArtifact (com.google.idea.blaze.base.command.buildresult.OutputArtifact)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1