use of org.gradle.internal.logging.text.TreeFormatter in project gradle by gradle.
the class IncompatibleDependencyAttributesMessageBuilder method buildMergeErrorMessage.
static String buildMergeErrorMessage(ModuleResolveState module, AttributeMergingException e) {
Attribute<?> attribute = e.getAttribute();
TreeFormatter fmt = new TreeFormatter();
fmt.node("Cannot select a variant of '" + module.getId());
fmt.append("' because different values for attribute '");
fmt.append(attribute.toString());
fmt.append("' are requested");
fmt.startChildren();
Set<EdgeState> incomingEdges = module.getIncomingEdges();
incomingEdges.addAll(module.getUnattachedDependencies());
for (EdgeState incomingEdge : incomingEdges) {
SelectorState selector = incomingEdge.getSelector();
for (String path : pathTo(incomingEdge, false)) {
String requestedAttribute = formatAttributeQuery(selector, attribute);
fmt.node(path + " " + requestedAttribute);
}
}
fmt.endChildren();
return fmt.toString();
}
use of org.gradle.internal.logging.text.TreeFormatter in project gradle by gradle.
the class NoMatchingConfigurationSelectionException method generateMessage.
private static String generateMessage(AttributeDescriber describer, AttributeContainerInternal fromConfigurationAttributes, AttributeMatcher attributeMatcher, final ComponentResolveMetadata targetComponent, boolean variantAware) {
Map<String, ConfigurationMetadata> configurations = new TreeMap<>();
Optional<ImmutableList<? extends ConfigurationMetadata>> variantsForGraphTraversal = targetComponent.getVariantsForGraphTraversal();
ImmutableList<? extends ConfigurationMetadata> variantsParticipatingInSelection = variantsForGraphTraversal.or(new LegacyConfigurationsSupplier(targetComponent));
for (ConfigurationMetadata configurationMetadata : variantsParticipatingInSelection) {
configurations.put(configurationMetadata.getName(), configurationMetadata);
}
TreeFormatter formatter = new TreeFormatter();
String targetVariantText = style(StyledTextOutput.Style.Info, targetComponent.getId().getDisplayName());
if (fromConfigurationAttributes.isEmpty()) {
formatter.node("Unable to find a matching " + (variantAware ? "variant" : "configuration") + " of " + targetVariantText);
} else {
formatter.node("No matching " + (variantAware ? "variant" : "configuration") + " of " + targetVariantText + " was found. The consumer was configured to find " + describer.describeAttributeSet(fromConfigurationAttributes.asMap()) + " but:");
}
formatter.startChildren();
if (configurations.isEmpty()) {
formatter.node("None of the " + (variantAware ? "variants" : "consumable configurations") + " have attributes.");
} else {
// to make sure the output is consistently the same between invocations
for (ConfigurationMetadata configuration : configurations.values()) {
formatConfiguration(formatter, targetComponent, fromConfigurationAttributes, attributeMatcher, configuration, variantAware, false, describer);
}
}
formatter.endChildren();
return formatter.toString();
}
use of org.gradle.internal.logging.text.TreeFormatter 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.internal.logging.text.TreeFormatter in project gradle by gradle.
the class AmbiguousConfigurationSelectionException method generateMessage.
private static String generateMessage(AttributeDescriber describer, AttributeContainerInternal fromConfigurationAttributes, AttributeMatcher attributeMatcher, List<? extends ConfigurationMetadata> matches, Set<ConfigurationMetadata> discarded, ComponentResolveMetadata targetComponent, boolean variantAware) {
Map<String, ConfigurationMetadata> ambiguousConfigurations = new TreeMap<>();
for (ConfigurationMetadata match : matches) {
ambiguousConfigurations.put(match.getName(), match);
}
TreeFormatter formatter = new TreeFormatter();
String configTerm = variantAware ? "variants" : "configurations";
if (fromConfigurationAttributes.isEmpty()) {
formatter.node("Cannot choose between the following " + configTerm + " of ");
} else {
formatter.node("The consumer was configured to find " + describer.describeAttributeSet(fromConfigurationAttributes.asMap()) + ". However we cannot choose between the following " + configTerm + " of ");
}
formatter.append(style(StyledTextOutput.Style.Info, targetComponent.getId().getDisplayName()));
formatter.startChildren();
for (String configuration : ambiguousConfigurations.keySet()) {
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 (ConfigurationMetadata ambiguousConf : ambiguousConfigurations.values()) {
formatConfiguration(formatter, targetComponent, fromConfigurationAttributes, attributeMatcher, ambiguousConf, variantAware, true, describer);
}
formatter.endChildren();
if (!discarded.isEmpty()) {
formatter.node("The following " + configTerm + " were also considered but didn't match the requested attributes:");
formatter.startChildren();
discarded.stream().sorted(Comparator.comparing(ConfigurationMetadata::getName)).forEach(discardedConf -> formatConfiguration(formatter, targetComponent, fromConfigurationAttributes, attributeMatcher, discardedConf, variantAware, false, describer));
formatter.endChildren();
}
return formatter.toString();
}
use of org.gradle.internal.logging.text.TreeFormatter 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();
}
Aggregations