use of org.gradle.internal.component.model.AttributeMatchingExplanationBuilder in project gradle by gradle.
the class AttributeMatchingVariantSelector method disambiguateWithSchema.
private List<Pair<ResolvedVariant, MutableConsumerVariantMatchResult.ConsumerVariant>> disambiguateWithSchema(AttributeMatcher matcher, List<Pair<ResolvedVariant, MutableConsumerVariantMatchResult.ConsumerVariant>> candidates, ImmutableAttributes componentRequested, AttributeMatchingExplanationBuilder explanationBuilder) {
List<AttributeContainerInternal> candidateAttributes = candidates.stream().map(pair -> pair.getRight().attributes).collect(Collectors.toList());
List<AttributeContainerInternal> matches = matcher.matches(candidateAttributes, componentRequested, explanationBuilder);
if (matches.size() == 1) {
AttributeContainerInternal singleMatch = matches.get(0);
return candidates.stream().filter(pair -> pair.getRight().attributes.equals(singleMatch)).collect(Collectors.toList());
} else if (matches.size() > 0 && matches.size() < candidates.size()) {
// We know all are compatibles, so this is only possible if some disambiguation happens but not getting us to 1 candidate
return candidates.stream().filter(pair -> matches.contains(pair.getRight().attributes)).collect(Collectors.toList());
}
return candidates;
}
Aggregations