Search in sources :

Example 6 with ComponentSelectionDescriptorInternal

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

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

the class SelectorState method addReasonsForSelector.

/**
 * Append selection descriptors to the supplied "reason", enhancing with any 'unmatched' or 'rejected' reasons.
 */
public void addReasonsForSelector(ComponentSelectionReasonInternal selectionReason) {
    ComponentIdResolveResult result = preferResult == null ? requireResult : preferResult;
    Collection<String> rejectedBySelector = null;
    if (result != null) {
        for (RejectedVersion rejectedVersion : result.getRejectedVersions()) {
            String version = rejectedVersion.getId().getVersion();
            if (rejectedVersion instanceof RejectedBySelectorVersion) {
                if (rejectedBySelector == null) {
                    rejectedBySelector = Lists.newArrayList();
                }
                rejectedBySelector.add(version);
            } else if (rejectedVersion instanceof RejectedByRuleVersion) {
                String reason = ((RejectedByRuleVersion) rejectedVersion).getReason();
                selectionReason.addCause(ComponentSelectionReasons.REJECTION.withDescription(new RejectedByRuleReason(version, reason)));
            } else if (rejectedVersion instanceof RejectedByAttributesVersion) {
                selectionReason.addCause(ComponentSelectionReasons.REJECTION.withDescription(new RejectedByAttributesReason((RejectedByAttributesVersion) rejectedVersion)));
            }
        }
    }
    for (ComponentSelectionDescriptorInternal descriptor : dependencyReasons) {
        if (descriptor.getCause() == ComponentSelectionCause.REQUESTED || descriptor.getCause() == ComponentSelectionCause.CONSTRAINT) {
            if (rejectedBySelector != null) {
                descriptor = descriptor.withDescription(new RejectedBySelectorReason(rejectedBySelector, descriptor));
            } else if (result != null && !result.getUnmatchedVersions().isEmpty()) {
                descriptor = descriptor.withDescription(new UnmatchedVersionsReason(result.getUnmatchedVersions(), descriptor));
            }
        }
        selectionReason.addCause(descriptor);
    }
}
Also used : RejectedVersion(org.gradle.internal.resolve.RejectedVersion) RejectedByRuleVersion(org.gradle.internal.resolve.RejectedByRuleVersion) DefaultBuildableComponentIdResolveResult(org.gradle.internal.resolve.result.DefaultBuildableComponentIdResolveResult) BuildableComponentIdResolveResult(org.gradle.internal.resolve.result.BuildableComponentIdResolveResult) ComponentIdResolveResult(org.gradle.internal.resolve.result.ComponentIdResolveResult) RejectedByAttributesVersion(org.gradle.internal.resolve.RejectedByAttributesVersion) ComponentSelectionDescriptorInternal(org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal) RejectedBySelectorVersion(org.gradle.internal.resolve.RejectedBySelectorVersion)

Example 8 with ComponentSelectionDescriptorInternal

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

the class DefaultConflictHandler method maybeSetReason.

private void maybeSetReason(Set<ModuleIdentifier> partifipants, ComponentResolutionState selected) {
    for (ModuleIdentifier identifier : partifipants) {
        ModuleReplacementsData.Replacement replacement = moduleReplacements.getReplacementFor(identifier);
        if (replacement != null) {
            String reason = replacement.getReason();
            ComponentSelectionDescriptorInternal moduleReplacement = ComponentSelectionReasons.SELECTED_BY_RULE.withDescription(Describables.of(identifier, "replaced with", replacement.getTarget()));
            if (reason != null) {
                moduleReplacement = moduleReplacement.withDescription(Describables.of(reason));
            }
            selected.addCause(moduleReplacement);
        }
    }
}
Also used : ModuleReplacementsData(org.gradle.api.internal.artifacts.dsl.ModuleReplacementsData) ComponentSelectionDescriptorInternal(org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Example 9 with ComponentSelectionDescriptorInternal

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

the class VersionConflictResolutionDetails method mergeCauses.

/**
 * For a single module, conflict resolution can happen several times. However, we want to keep only one version
 * conflict resolution cause, listing all modules which participated in resolution. So this method is going to iterate
 * over all causes, and if it finds that version conflict resolution kicked in several times, will merge all candidates
 * in order to report it once with all candidates.
 *
 * This method tries its best not to create new lists if not required.
 *
 * @param descriptors all selection descriptors
 * @return a filtered descriptors list, with merged conflict version resolution
 */
public static List<ComponentSelectionDescriptorInternal> mergeCauses(List<ComponentSelectionDescriptorInternal> descriptors) {
    List<VersionConflictResolutionDetails> byVersionConflictResolution = collectVersionConflictCandidates(descriptors);
    if (byVersionConflictResolution != null && byVersionConflictResolution.size() > 1) {
        Set<ComponentResolutionState> allCandidates = mergeAllCandidates(byVersionConflictResolution);
        List<ComponentSelectionDescriptorInternal> merged = Lists.newArrayListWithCapacity(descriptors.size() - 1);
        boolean added = false;
        for (ComponentSelectionDescriptorInternal descriptor : descriptors) {
            if (isByVersionConflict(descriptor)) {
                if (!added) {
                    merged.add(ComponentSelectionReasons.CONFLICT_RESOLUTION.withDescription(new VersionConflictResolutionDetails(allCandidates)));
                }
                added = true;
            } else {
                merged.add(descriptor);
            }
        }
        return merged;
    }
    return descriptors;
}
Also used : ComponentResolutionState(org.gradle.api.internal.artifacts.ivyservice.resolveengine.ComponentResolutionState) ComponentSelectionDescriptorInternal(org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal)

Example 10 with ComponentSelectionDescriptorInternal

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

the class DefaultCapabilitiesConflictHandler method resolveNextConflict.

@Override
public void resolveNextConflict(Action<ConflictResolutionResult> resolutionAction) {
    CapabilityConflict conflict = conflicts.poll();
    Details details = new Details(conflict);
    for (Resolver resolver : resolvers) {
        resolver.resolve(details);
        if (details.hasResult()) {
            resolutionAction.execute(details);
            ComponentSelectionDescriptorInternal conflictResolution = ComponentSelectionReasons.CONFLICT_RESOLUTION;
            if (details.reason != null) {
                conflictResolution = conflictResolution.withDescription(details.reason);
            }
            details.getSelected().addCause(conflictResolution);
            return;
        }
    }
}
Also used : ComponentSelectionDescriptorInternal(org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal)

Aggregations

ComponentSelectionDescriptorInternal (org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal)12 ModuleIdentifier (org.gradle.api.artifacts.ModuleIdentifier)2 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)2 ComponentSelectionDescriptor (org.gradle.api.artifacts.result.ComponentSelectionDescriptor)2 ComponentSelectionReasonInternal (org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionReasonInternal)2 DefaultModuleComponentSelector (org.gradle.internal.component.external.model.DefaultModuleComponentSelector)2 Action (org.gradle.api.Action)1 ArtifactSelectionDetails (org.gradle.api.artifacts.ArtifactSelectionDetails)1 DependencySubstitution (org.gradle.api.artifacts.DependencySubstitution)1 ComponentSelector (org.gradle.api.artifacts.component.ComponentSelector)1 ProjectComponentSelector (org.gradle.api.artifacts.component.ProjectComponentSelector)1 ModuleReplacementsData (org.gradle.api.internal.artifacts.dsl.ModuleReplacementsData)1 ComponentResolutionState (org.gradle.api.internal.artifacts.ivyservice.resolveengine.ComponentResolutionState)1 DefaultConflictResolverDetails (org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.conflicts.DefaultConflictResolverDetails)1 VersionConflictResolutionDetails (org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.conflicts.VersionConflictResolutionDetails)1 DefaultSection (org.gradle.api.tasks.diagnostics.internal.graph.nodes.DefaultSection)1 Section (org.gradle.api.tasks.diagnostics.internal.graph.nodes.Section)1 DefaultProjectComponentSelector (org.gradle.internal.component.local.model.DefaultProjectComponentSelector)1 RejectedByAttributesVersion (org.gradle.internal.resolve.RejectedByAttributesVersion)1 RejectedByRuleVersion (org.gradle.internal.resolve.RejectedByRuleVersion)1