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