Search in sources :

Example 6 with ComponentIdResolveResult

use of org.gradle.internal.resolve.result.ComponentIdResolveResult in project gradle by gradle.

the class SelectorStateResolverResults method replaceExistingResolutionsWithBetterResult.

boolean replaceExistingResolutionsWithBetterResult(ComponentIdResolveResult candidate, boolean isFromLock) {
    // Check already-resolved dependencies and use this version if it's compatible
    boolean replaces = false;
    for (Registration registration : results) {
        ComponentIdResolveResult previous = registration.result;
        ResolvableSelectorState previousSelector = registration.selector;
        if (emptyVersion(previous) || sameVersion(previous, candidate) || (selectorAcceptsCandidate(previousSelector, candidate, isFromLock) && lowerVersion(previous, candidate))) {
            registration.result = candidate;
            replaces = true;
        }
    }
    return replaces;
}
Also used : ComponentIdResolveResult(org.gradle.internal.resolve.result.ComponentIdResolveResult)

Example 7 with ComponentIdResolveResult

use of org.gradle.internal.resolve.result.ComponentIdResolveResult in project gradle by gradle.

the class SelectorStateResolverResults method getResolved.

public <T extends ComponentResolutionState> List<T> getResolved(ComponentStateFactory<T> componentFactory) {
    ModuleVersionResolveException failure = null;
    List<T> resolved = null;
    boolean hasSoftForce = hasSoftForce();
    for (Registration entry : results) {
        ResolvableSelectorState selectorState = entry.selector;
        ComponentIdResolveResult idResolveResult = entry.result;
        if (selectorState.isForce() && !hasSoftForce) {
            T forcedComponent = componentForIdResolveResult(componentFactory, idResolveResult, selectorState);
            return Collections.singletonList(forcedComponent);
        }
        if (idResolveResult.mark(this)) {
            if (idResolveResult.getFailure() == null) {
                T componentState = componentForIdResolveResult(componentFactory, idResolveResult, selectorState);
                if (resolved == null) {
                    resolved = Lists.newArrayList();
                }
                resolved.add(componentState);
            } else {
                if (failure == null) {
                    failure = idResolveResult.getFailure();
                }
            }
        }
    }
    if (resolved == null && failure != null) {
        throw failure;
    }
    return resolved == null ? Collections.emptyList() : resolved;
}
Also used : ComponentIdResolveResult(org.gradle.internal.resolve.result.ComponentIdResolveResult) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException)

Example 8 with ComponentIdResolveResult

use of org.gradle.internal.resolve.result.ComponentIdResolveResult in project gradle by gradle.

the class SelectorStateResolverResults method alreadyHaveResolutionForSelector.

/**
 * Check already resolved results for a compatible version, and use it for this dependency rather than re-resolving.
 */
boolean alreadyHaveResolutionForSelector(ResolvableSelectorState selector) {
    for (Registration registration : results) {
        ComponentIdResolveResult discovered = registration.result;
        if (selectorAcceptsCandidate(selector, discovered, registration.selector.isFromLock())) {
            register(selector, discovered);
            selector.markResolved();
            return true;
        }
    }
    return false;
}
Also used : ComponentIdResolveResult(org.gradle.internal.resolve.result.ComponentIdResolveResult)

Example 9 with ComponentIdResolveResult

use of org.gradle.internal.resolve.result.ComponentIdResolveResult 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

ComponentIdResolveResult (org.gradle.internal.resolve.result.ComponentIdResolveResult)9 ComponentSelectionDescriptorInternal (org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal)1 ModuleVersionResolveException (org.gradle.internal.resolve.ModuleVersionResolveException)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 DefaultBuildableComponentIdResolveResult (org.gradle.internal.resolve.result.DefaultBuildableComponentIdResolveResult)1