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