Search in sources :

Example 1 with TreeFormatter

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

the class ToolChainAvailability method getUnavailableMessage.

public String getUnavailableMessage() {
    TreeFormatter formatter = new TreeFormatter();
    this.explain(formatter);
    return formatter.toString();
}
Also used : TreeFormatter(org.gradle.internal.text.TreeFormatter)

Example 2 with TreeFormatter

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

the class NotFoundScalaToolProvider method failure.

private RuntimeException failure() {
    TreeFormatter formatter = new TreeFormatter();
    this.explain(formatter);
    return new GradleException(formatter.toString(), exception);
}
Also used : TreeFormatter(org.gradle.internal.text.TreeFormatter) GradleException(org.gradle.api.GradleException)

Example 3 with TreeFormatter

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

the class AbstractBinaryRenderer method renderBuildAbility.

private void renderBuildAbility(BinarySpec binary, TextReportBuilder builder) {
    BinaryBuildAbility buildAbility = ((BinarySpecInternal) binary).getBuildAbility();
    if (!buildAbility.isBuildable()) {
        TreeFormatter formatter = new TreeFormatter();
        buildAbility.explain(formatter);
        builder.item(formatter.toString());
    }
}
Also used : BinarySpecInternal(org.gradle.platform.base.internal.BinarySpecInternal) BinaryBuildAbility(org.gradle.platform.base.internal.BinaryBuildAbility) TreeFormatter(org.gradle.internal.text.TreeFormatter)

Example 4 with TreeFormatter

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

the class IncompatibleConfigurationSelectionException method generateMessage.

private static String generateMessage(AttributeContainer fromConfigurationAttributes, AttributesSchema consumerSchema, ComponentResolveMetadata targetComponent, String targetConfiguration) {
    Set<String> requestedAttributes = Sets.newTreeSet(Iterables.transform(fromConfigurationAttributes.keySet(), ATTRIBUTE_NAME));
    TreeFormatter formatter = new TreeFormatter();
    formatter.node("Configuration '" + targetConfiguration + "' in " + targetComponent.getComponentId().getDisplayName() + " does not match the consumer attributes");
    formatConfiguration(formatter, fromConfigurationAttributes, consumerSchema, Collections.singletonList(targetComponent.getConfiguration(targetConfiguration)), requestedAttributes, targetConfiguration);
    return formatter.toString();
}
Also used : TreeFormatter(org.gradle.internal.text.TreeFormatter)

Example 5 with TreeFormatter

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

the class NoMatchingConfigurationSelectionException method generateMessage.

private static String generateMessage(AttributeContainer fromConfigurationAttributes, AttributesSchema consumerSchema, ComponentResolveMetadata targetComponent, List<String> configurationNames) {
    List<ConfigurationMetadata> configurations = new ArrayList<ConfigurationMetadata>(configurationNames.size());
    for (String name : configurationNames) {
        ConfigurationMetadata targetComponentConfiguration = targetComponent.getConfiguration(name);
        if (targetComponentConfiguration.isCanBeConsumed() && !targetComponentConfiguration.getAttributes().isEmpty()) {
            configurations.add(targetComponentConfiguration);
        }
    }
    Set<String> requestedAttributes = Sets.newTreeSet(Iterables.transform(fromConfigurationAttributes.keySet(), ATTRIBUTE_NAME));
    TreeFormatter formatter = new TreeFormatter();
    formatter.node("Unable to find a matching configuration in " + targetComponent.getComponentId().getDisplayName());
    formatter.startChildren();
    if (configurations.isEmpty()) {
        formatter.node("None of the consumable configurations have attributes.");
    } else {
        // to make sure the output is consistently the same between invocations
        for (String config : configurationNames) {
            formatConfiguration(formatter, fromConfigurationAttributes, consumerSchema, configurations, requestedAttributes, config);
        }
    }
    formatter.endChildren();
    return formatter.toString();
}
Also used : TreeFormatter(org.gradle.internal.text.TreeFormatter) ArrayList(java.util.ArrayList) ConfigurationMetadata(org.gradle.internal.component.model.ConfigurationMetadata)

Aggregations

TreeFormatter (org.gradle.internal.text.TreeFormatter)7 GradleException (org.gradle.api.GradleException)2 ArrayList (java.util.ArrayList)1 ConfigurationMetadata (org.gradle.internal.component.model.ConfigurationMetadata)1 BinaryBuildAbility (org.gradle.platform.base.internal.BinaryBuildAbility)1 BinarySpecInternal (org.gradle.platform.base.internal.BinarySpecInternal)1