Search in sources :

Example 1 with ComponentSelectionDescriptor

use of org.gradle.api.artifacts.result.ComponentSelectionDescriptor in project gradle by gradle.

the class ComponentSelectionReasonSerializer method readDescriptions.

private List<ComponentSelectionDescriptor> readDescriptions(Decoder decoder) throws IOException {
    int size = decoder.readSmallInt();
    ImmutableList.Builder<ComponentSelectionDescriptor> builder = new ImmutableList.Builder<ComponentSelectionDescriptor>();
    for (int i = 0; i < size; i++) {
        ComponentSelectionCause cause = ComponentSelectionCause.values()[decoder.readByte()];
        String desc = readDescriptionText(decoder);
        builder.add(new DefaultComponentSelectionDescriptor(cause, desc));
    }
    return builder.build();
}
Also used : ComponentSelectionDescriptor(org.gradle.api.artifacts.result.ComponentSelectionDescriptor) ImmutableList(com.google.common.collect.ImmutableList) ComponentSelectionCause(org.gradle.api.artifacts.result.ComponentSelectionCause)

Example 2 with ComponentSelectionDescriptor

use of org.gradle.api.artifacts.result.ComponentSelectionDescriptor in project gradle by gradle.

the class RejectedModuleMessageBuilder method renderReason.

private static void renderReason(StringBuilder sb, SelectorState selector) {
    ComponentSelectionReasonInternal selectionReason = selector.getSelectionReason();
    if (selectionReason.hasCustomDescriptions()) {
        sb.append(" because of the following reason");
        List<String> reasons = Lists.newArrayListWithExpectedSize(1);
        for (ComponentSelectionDescriptor componentSelectionDescriptor : selectionReason.getDescriptions()) {
            ComponentSelectionDescriptorInternal next = (ComponentSelectionDescriptorInternal) componentSelectionDescriptor;
            if (next.hasCustomDescription()) {
                reasons.add(next.getDescription());
            }
        }
        if (reasons.size() == 1) {
            sb.append(": ").append(reasons.get(0));
        } else {
            sb.append("s: ");
            Joiner.on(", ").appendTo(sb, reasons);
        }
    }
}
Also used : ComponentSelectionDescriptor(org.gradle.api.artifacts.result.ComponentSelectionDescriptor) ComponentSelectionDescriptorInternal(org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal) ComponentSelectionReasonInternal(org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionReasonInternal)

Example 3 with ComponentSelectionDescriptor

use of org.gradle.api.artifacts.result.ComponentSelectionDescriptor in project gradle by gradle.

the class ComponentSelectionReasonSerializer method write.

@Override
public void write(Encoder encoder, ComponentSelectionReason value) throws IOException {
    List<ComponentSelectionDescriptor> descriptions = value.getDescriptions();
    encoder.writeSmallInt(descriptions.size());
    for (ComponentSelectionDescriptor description : descriptions) {
        componentSelectionDescriptorSerializer.write(encoder, description);
    }
}
Also used : ComponentSelectionDescriptor(org.gradle.api.artifacts.result.ComponentSelectionDescriptor)

Example 4 with ComponentSelectionDescriptor

use of org.gradle.api.artifacts.result.ComponentSelectionDescriptor in project gradle by gradle.

the class DependencyInsightReporter method buildSelectionReasonSection.

private static DefaultSection buildSelectionReasonSection(ComponentSelectionReason reason) {
    DefaultSection selectionReasons = new DefaultSection("Selection reasons");
    for (ComponentSelectionDescriptor entry : reason.getDescriptions()) {
        ComponentSelectionDescriptorInternal descriptor = (ComponentSelectionDescriptorInternal) entry;
        boolean hasCustomDescription = descriptor.hasCustomDescription();
        if (ComponentSelectionReasons.isCauseExpected(descriptor) && !hasCustomDescription) {
            // Don't render empty 'requested' reason
            continue;
        }
        Section item = new DefaultSection(render(descriptor));
        selectionReasons.addChild(item);
    }
    return selectionReasons;
}
Also used : ComponentSelectionDescriptor(org.gradle.api.artifacts.result.ComponentSelectionDescriptor) ComponentSelectionDescriptorInternal(org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal) DefaultSection(org.gradle.api.tasks.diagnostics.internal.graph.nodes.DefaultSection) Section(org.gradle.api.tasks.diagnostics.internal.graph.nodes.Section) DefaultSection(org.gradle.api.tasks.diagnostics.internal.graph.nodes.DefaultSection)

Aggregations

ComponentSelectionDescriptor (org.gradle.api.artifacts.result.ComponentSelectionDescriptor)4 ComponentSelectionDescriptorInternal (org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal)2 ImmutableList (com.google.common.collect.ImmutableList)1 ComponentSelectionCause (org.gradle.api.artifacts.result.ComponentSelectionCause)1 ComponentSelectionReasonInternal (org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionReasonInternal)1 DefaultSection (org.gradle.api.tasks.diagnostics.internal.graph.nodes.DefaultSection)1 Section (org.gradle.api.tasks.diagnostics.internal.graph.nodes.Section)1