Search in sources :

Example 1 with RejectedBySelectorVersion

use of org.gradle.internal.resolve.RejectedBySelectorVersion 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)

Aggregations

ComponentSelectionDescriptorInternal (org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal)1 RejectedByAttributesVersion (org.gradle.internal.resolve.RejectedByAttributesVersion)1 RejectedByRuleVersion (org.gradle.internal.resolve.RejectedByRuleVersion)1 RejectedBySelectorVersion (org.gradle.internal.resolve.RejectedBySelectorVersion)1 RejectedVersion (org.gradle.internal.resolve.RejectedVersion)1 BuildableComponentIdResolveResult (org.gradle.internal.resolve.result.BuildableComponentIdResolveResult)1 ComponentIdResolveResult (org.gradle.internal.resolve.result.ComponentIdResolveResult)1 DefaultBuildableComponentIdResolveResult (org.gradle.internal.resolve.result.DefaultBuildableComponentIdResolveResult)1