use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvedVariant in project gradle by gradle.
the class NoMatchingVariantSelectionException method format.
private static String format(String producerDisplayName, AttributeContainerInternal consumer, Collection<? extends ResolvedVariant> candidates, AttributeMatcher matcher) {
TreeFormatter formatter = new TreeFormatter();
formatter.node("No variants of " + producerDisplayName + " match the consumer attributes");
formatter.startChildren();
for (ResolvedVariant variant : candidates) {
formatter.node(variant.asDescribable().getCapitalizedDisplayName());
formatAttributeMatches(formatter, consumer, matcher, variant.getAttributes());
}
formatter.endChildren();
return formatter.toString();
}
use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvedVariant in project gradle by gradle.
the class AmbiguousVariantSelectionException method format.
private static String format(AttributeDescriber describer, String producerDisplayName, AttributeContainerInternal consumer, List<? extends ResolvedVariant> variants, AttributeMatcher matcher, Set<ResolvedVariant> discarded) {
TreeFormatter formatter = new TreeFormatter();
if (consumer.getAttributes().isEmpty()) {
formatter.node("More than one variant of " + producerDisplayName + " matches the consumer attributes");
} else {
formatter.node("The consumer was configured to find " + describer.describeAttributeSet(consumer.asMap()) + ". However we cannot choose between the following variants of " + producerDisplayName);
}
formatter.startChildren();
for (ResolvedVariant variant : variants) {
formatter.node(variant.asDescribable().getCapitalizedDisplayName());
formatAttributeMatchesForAmbiguity(formatter, consumer.asImmutable(), matcher, variant.getAttributes().asImmutable(), describer);
}
formatter.endChildren();
if (!discarded.isEmpty()) {
formatter.node("The following variants were also considered but didn't match the requested attributes:");
formatter.startChildren();
discarded.stream().sorted(Comparator.comparing(v -> v.asDescribable().getCapitalizedDisplayName())).forEach(discardedVariant -> {
formatter.node(discardedVariant.asDescribable().getCapitalizedDisplayName());
formatAttributeMatchesForIncompatibility(formatter, consumer.asImmutable(), matcher, discardedVariant.getAttributes().asImmutable(), describer);
});
formatter.endChildren();
}
return formatter.toString();
}
use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvedVariant in project gradle by gradle.
the class NoMatchingVariantSelectionException method format.
private static String format(String producerDisplayName, AttributeContainerInternal consumer, Collection<? extends ResolvedVariant> candidates, AttributeMatcher matcher, AttributeDescriber describer) {
TreeFormatter formatter = new TreeFormatter();
formatter.node("No variants of " + style(StyledTextOutput.Style.Info, producerDisplayName) + " match the consumer attributes");
formatter.startChildren();
for (ResolvedVariant variant : candidates) {
formatter.node(variant.asDescribable().getCapitalizedDisplayName());
formatAttributeMatchesForIncompatibility(formatter, consumer.asImmutable(), matcher, variant.getAttributes().asImmutable(), describer);
}
formatter.endChildren();
return formatter.toString();
}
use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvedVariant in project gradle by gradle.
the class AttributeMatchingVariantSelector method doSelect.
private ResolvedArtifactSet doSelect(ResolvedVariantSet producer) {
AttributeMatcher matcher = schema.withProducer(producer.getSchema());
List<? extends ResolvedVariant> matches = matcher.matches(producer.getVariants(), requested);
if (matches.size() == 1) {
return matches.get(0).getArtifacts();
}
if (matches.size() > 1) {
throw new AmbiguousVariantSelectionException(producer.asDescribable().getDisplayName(), requested, matches, matcher);
}
List<Pair<ResolvedVariant, ConsumerVariantMatchResult.ConsumerVariant>> candidates = new ArrayList<Pair<ResolvedVariant, ConsumerVariantMatchResult.ConsumerVariant>>();
for (ResolvedVariant variant : producer.getVariants()) {
AttributeContainerInternal variantAttributes = variant.getAttributes().asImmutable();
ConsumerVariantMatchResult matchResult = new ConsumerVariantMatchResult();
consumerProvidedVariantFinder.collectConsumerVariants(variantAttributes, requested, matchResult);
for (ConsumerVariantMatchResult.ConsumerVariant consumerVariant : matchResult.getMatches()) {
candidates.add(Pair.of(variant, consumerVariant));
}
}
if (candidates.size() == 1) {
Pair<ResolvedVariant, ConsumerVariantMatchResult.ConsumerVariant> result = candidates.get(0);
return new ConsumerProvidedResolvedVariant(result.getLeft().getArtifacts(), result.getRight().attributes, result.getRight().transformer);
}
if (!candidates.isEmpty()) {
throw new AmbiguousTransformException(producer.asDescribable().getDisplayName(), requested, candidates);
}
if (ignoreWhenNoMatches) {
return ResolvedArtifactSet.EMPTY;
}
throw new NoMatchingVariantSelectionException(producer.asDescribable().getDisplayName(), requested, producer.getVariants(), matcher);
}
use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvedVariant in project gradle by gradle.
the class AmbiguousVariantSelectionException method format.
private static String format(String producerDisplayName, AttributeContainerInternal consumer, List<? extends ResolvedVariant> variants, AttributeMatcher matcher) {
TreeFormatter formatter = new TreeFormatter();
formatter.node("More than one variant of " + producerDisplayName + " matches the consumer attributes");
formatter.startChildren();
for (ResolvedVariant variant : variants) {
formatter.node(variant.asDescribable().getCapitalizedDisplayName());
formatAttributeMatches(formatter, consumer, matcher, variant.getAttributes());
}
formatter.endChildren();
return formatter.toString();
}
Aggregations