Search in sources :

Example 1 with AttributeMatchingExplanationBuilder

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;
}
Also used : BrokenResolvedArtifactSet(org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.BrokenResolvedArtifactSet) AttributesSchemaInternal(org.gradle.api.internal.attributes.AttributesSchemaInternal) AttributeMatcher(org.gradle.internal.component.model.AttributeMatcher) DescriberSelector(org.gradle.internal.component.model.DescriberSelector) ArrayList(java.util.ArrayList) Pair(org.gradle.internal.Pair) Lists(com.google.common.collect.Lists) Attribute(org.gradle.api.attributes.Attribute) AttributeDescriber(org.gradle.api.internal.attributes.AttributeDescriber) ResolvedArtifactSet(org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvedArtifactSet) ImmutableAttributes(org.gradle.api.internal.attributes.ImmutableAttributes) ResolvedVariant(org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvedVariant) ResolvedVariantSet(org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvedVariantSet) ImmutableAttributesFactory(org.gradle.api.internal.attributes.ImmutableAttributesFactory) Set(java.util.Set) Cast(org.gradle.internal.Cast) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) List(java.util.List) NoMatchingVariantSelectionException(org.gradle.internal.component.NoMatchingVariantSelectionException) AttributeMatchingExplanationBuilder(org.gradle.internal.component.model.AttributeMatchingExplanationBuilder) AttributeValue(org.gradle.api.internal.attributes.AttributeValue) Optional(java.util.Optional) VariantSelectionException(org.gradle.internal.component.VariantSelectionException) Comparator(java.util.Comparator) HasAttributes(org.gradle.api.attributes.HasAttributes) Collections(java.util.Collections) AmbiguousVariantSelectionException(org.gradle.internal.component.AmbiguousVariantSelectionException) AttributeContainerInternal(org.gradle.api.internal.attributes.AttributeContainerInternal) AttributeContainerInternal(org.gradle.api.internal.attributes.AttributeContainerInternal)

Aggregations

Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Attribute (org.gradle.api.attributes.Attribute)1 HasAttributes (org.gradle.api.attributes.HasAttributes)1 BrokenResolvedArtifactSet (org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.BrokenResolvedArtifactSet)1 ResolvedArtifactSet (org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvedArtifactSet)1 ResolvedVariant (org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvedVariant)1 ResolvedVariantSet (org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvedVariantSet)1 AttributeContainerInternal (org.gradle.api.internal.attributes.AttributeContainerInternal)1 AttributeDescriber (org.gradle.api.internal.attributes.AttributeDescriber)1 AttributeValue (org.gradle.api.internal.attributes.AttributeValue)1 AttributesSchemaInternal (org.gradle.api.internal.attributes.AttributesSchemaInternal)1 ImmutableAttributes (org.gradle.api.internal.attributes.ImmutableAttributes)1