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();
}
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);
}
}
}
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);
}
}
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;
}
Aggregations