Search in sources :

Example 1 with ComponentSelectionReasonInternal

use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionReasonInternal in project gradle by gradle.

the class ComponentState method getSelectionReason.

@Override
public ComponentSelectionReason getSelectionReason() {
    if (root) {
        return ComponentSelectionReasons.root();
    }
    if (cachedReason != null) {
        return cachedReason;
    }
    ComponentSelectionReasonInternal reason = ComponentSelectionReasons.empty();
    for (final SelectorState selectorState : module.getSelectors()) {
        if (selectorState.getFailure() == null) {
            selectorState.addReasonsForSelector(reason);
        }
    }
    for (ComponentSelectionDescriptorInternal selectionCause : VersionConflictResolutionDetails.mergeCauses(selectionCauses)) {
        reason.addCause(selectionCause);
    }
    cachedReason = reason;
    return reason;
}
Also used : ComponentSelectionDescriptorInternal(org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal) ComponentSelectionReasonInternal(org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionReasonInternal)

Example 2 with ComponentSelectionReasonInternal

use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionReasonInternal in project gradle by gradle.

the class DependencyInsightReporter method createHeaderForDependency.

private DependencyReportHeader createHeaderForDependency(DependencyEdge dependency, Set<Throwable> alreadyReportedErrors) {
    ComponentSelectionReasonInternal reason = (ComponentSelectionReasonInternal) dependency.getReason();
    Section selectionReasonsSection = buildSelectionReasonSection(reason);
    List<Section> reasonSections = selectionReasonsSection.getChildren();
    String reasonShortDescription;
    List<Section> extraDetails = Lists.newArrayList();
    boolean displayFullReasonSection = reason.hasCustomDescriptions() || reasonSections.size() > 1;
    if (displayFullReasonSection) {
        reasonShortDescription = null;
        extraDetails.add(selectionReasonsSection);
    } else {
        reasonShortDescription = reasonSections.isEmpty() ? null : reasonSections.get(0).getDescription().toLowerCase();
    }
    buildFailureSection(dependency, alreadyReportedErrors, extraDetails);
    List<ResolvedVariantResult> selectedVariants = dependency.getSelectedVariants();
    return new DependencyReportHeader(dependency, reasonShortDescription, selectedVariants, extraDetails);
}
Also used : ResolvedVariantResult(org.gradle.api.artifacts.result.ResolvedVariantResult) DependencyReportHeader(org.gradle.api.tasks.diagnostics.internal.graph.nodes.DependencyReportHeader) DefaultSection(org.gradle.api.tasks.diagnostics.internal.graph.nodes.DefaultSection) Section(org.gradle.api.tasks.diagnostics.internal.graph.nodes.Section) ComponentSelectionReasonInternal(org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionReasonInternal)

Example 3 with ComponentSelectionReasonInternal

use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionReasonInternal in project gradle by gradle.

the class SelectionReasonHelper method getReasonDescription.

public static String getReasonDescription(ComponentSelectionReason reason) {
    ComponentSelectionReasonInternal r = (ComponentSelectionReasonInternal) reason;
    String description = getReasonDescription(r);
    if (reason.isConstrained()) {
        if (!r.hasCustomDescriptions()) {
            return "via constraint";
        } else {
            return "via constraint, " + description;
        }
    }
    return description;
}
Also used : ComponentSelectionReasonInternal(org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionReasonInternal)

Example 4 with ComponentSelectionReasonInternal

use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionReasonInternal 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)

Aggregations

ComponentSelectionReasonInternal (org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionReasonInternal)4 ComponentSelectionDescriptorInternal (org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal)2 ComponentSelectionDescriptor (org.gradle.api.artifacts.result.ComponentSelectionDescriptor)1 ResolvedVariantResult (org.gradle.api.artifacts.result.ResolvedVariantResult)1 DefaultSection (org.gradle.api.tasks.diagnostics.internal.graph.nodes.DefaultSection)1 DependencyReportHeader (org.gradle.api.tasks.diagnostics.internal.graph.nodes.DependencyReportHeader)1 Section (org.gradle.api.tasks.diagnostics.internal.graph.nodes.Section)1