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