Search in sources :

Example 11 with TreeFormatter

use of org.gradle.internal.text.TreeFormatter in project gradle by gradle.

the class AmbiguousConfigurationSelectionException method generateMessage.

private static String generateMessage(AttributeContainer fromConfigurationAttributes, AttributesSchema consumerSchema, List<? extends ConfigurationMetadata> matches, ComponentResolveMetadata targetComponent) {
    Set<String> ambiguousConfigurations = Sets.newTreeSet(Lists.transform(matches, CONFIG_NAME));
    Set<String> requestedAttributes = Sets.newTreeSet(Iterables.transform(fromConfigurationAttributes.keySet(), ATTRIBUTE_NAME));
    TreeFormatter formatter = new TreeFormatter();
    formatter.node("Cannot choose between the following configurations on ");
    formatter.append(targetComponent.getComponentId().getDisplayName());
    formatter.startChildren();
    for (String configuration : ambiguousConfigurations) {
        formatter.node(configuration);
    }
    formatter.endChildren();
    formatter.node("All of them match the consumer attributes");
    // We're sorting the names of the configurations and later attributes
    // to make sure the output is consistently the same between invocations
    formatter.startChildren();
    for (final String ambiguousConf : ambiguousConfigurations) {
        formatConfiguration(formatter, fromConfigurationAttributes, consumerSchema, matches, requestedAttributes, ambiguousConf);
    }
    formatter.endChildren();
    return formatter.toString();
}
Also used : TreeFormatter(org.gradle.internal.text.TreeFormatter)

Example 12 with TreeFormatter

use of org.gradle.internal.text.TreeFormatter in project gradle by gradle.

the class AmbiguousTransformException method format.

private static String format(String producerDisplayName, AttributeContainerInternal requested, List<Pair<ResolvedVariant, ConsumerVariantMatchResult.ConsumerVariant>> candidates) {
    TreeFormatter formatter = new TreeFormatter();
    formatter.node("Found multiple transforms that can produce a variant of " + producerDisplayName + " for consumer attributes");
    formatAttributes(formatter, requested);
    formatter.node("Found the following transforms");
    formatter.startChildren();
    for (Pair<ResolvedVariant, ConsumerVariantMatchResult.ConsumerVariant> candidate : candidates) {
        formatter.node("Transform from " + candidate.getLeft().asDescribable().getDisplayName());
        formatAttributes(formatter, candidate.getLeft().getAttributes());
    }
    formatter.endChildren();
    return formatter.toString();
}
Also used : TreeFormatter(org.gradle.internal.text.TreeFormatter) ResolvedVariant(org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvedVariant)

Example 13 with TreeFormatter

use of org.gradle.internal.text.TreeFormatter 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();
}
Also used : TreeFormatter(org.gradle.internal.text.TreeFormatter) ResolvedVariant(org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvedVariant)

Example 14 with TreeFormatter

use of org.gradle.internal.text.TreeFormatter in project gradle by gradle.

the class IncompatibleConfigurationSelectionException method generateMessage.

private static String generateMessage(AttributeContainerInternal fromConfigurationAttributes, AttributeMatcher attributeMatcher, ComponentResolveMetadata targetComponent, String targetConfiguration) {
    TreeFormatter formatter = new TreeFormatter();
    formatter.node("Configuration '" + targetConfiguration + "' in " + targetComponent.getId().getDisplayName() + " does not match the consumer attributes");
    formatConfiguration(formatter, fromConfigurationAttributes, attributeMatcher, targetComponent.getConfiguration(targetConfiguration));
    return formatter.toString();
}
Also used : TreeFormatter(org.gradle.internal.text.TreeFormatter)

Aggregations

TreeFormatter (org.gradle.internal.text.TreeFormatter)14 ResolvedVariant (org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvedVariant)3 ConfigurationMetadata (org.gradle.internal.component.model.ConfigurationMetadata)3 ArrayList (java.util.ArrayList)2 TreeMap (java.util.TreeMap)2 GradleException (org.gradle.api.GradleException)2 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 ComponentWithVariants (org.gradle.api.component.ComponentWithVariants)1 SoftwareComponent (org.gradle.api.component.SoftwareComponent)1 DefaultModuleVersionIdentifier (org.gradle.api.internal.artifacts.DefaultModuleVersionIdentifier)1 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)1 BinaryBuildAbility (org.gradle.platform.base.internal.BinaryBuildAbility)1 BinarySpecInternal (org.gradle.platform.base.internal.BinarySpecInternal)1