Search in sources :

Example 1 with ComponentResolutionState

use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.ComponentResolutionState in project gradle by gradle.

the class VersionConflictResolutionDetails method getDisplayName.

@Override
public String getDisplayName() {
    StringBuilder sb = new StringBuilder(16 + 16 * candidates.size());
    sb.append("between versions ");
    Iterator<? extends ComponentResolutionState> it = candidates.iterator();
    boolean more = false;
    while (it.hasNext()) {
        ComponentResolutionState next = it.next();
        if (more) {
            if (it.hasNext()) {
                sb.append(", ");
            } else {
                sb.append(" and ");
            }
        }
        more = true;
        sb.append(next.getId().getVersion());
    }
    return sb.toString();
}
Also used : ComponentResolutionState(org.gradle.api.internal.artifacts.ivyservice.resolveengine.ComponentResolutionState)

Example 2 with ComponentResolutionState

use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.ComponentResolutionState in project gradle by gradle.

the class DefaultConflictHandler method resolveNextConflict.

/**
 * Resolves the conflict by delegating to the conflict resolver who selects single version from given candidates. Executes provided action against the conflict resolution result object.
 */
@Override
public void resolveNextConflict(Action<ConflictResolutionResult> resolutionAction) {
    assert hasConflicts();
    ConflictContainer<ModuleIdentifier, ComponentState>.Conflict conflict = conflicts.popConflict();
    ConflictResolverDetails<ComponentState> details = new DefaultConflictResolverDetails<>(conflict.candidates);
    compositeResolver.select(details);
    if (details.hasFailure()) {
        throw UncheckedException.throwAsUncheckedException(details.getFailure());
    }
    ComponentResolutionState selected = details.getSelected();
    ConflictResolutionResult result = new DefaultConflictResolutionResult(conflict.participants, selected);
    resolutionAction.execute(result);
    if (selected != null) {
        maybeSetReason(conflict.participants, selected);
    }
    LOGGER.debug("Selected {} from conflicting modules {}.", selected, conflict.candidates);
}
Also used : ComponentResolutionState(org.gradle.api.internal.artifacts.ivyservice.resolveengine.ComponentResolutionState) ComponentState(org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.ComponentState)

Example 3 with ComponentResolutionState

use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.ComponentResolutionState 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;
}
Also used : ComponentResolutionState(org.gradle.api.internal.artifacts.ivyservice.resolveengine.ComponentResolutionState) ComponentSelectionDescriptorInternal(org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal)

Aggregations

ComponentResolutionState (org.gradle.api.internal.artifacts.ivyservice.resolveengine.ComponentResolutionState)3 ComponentState (org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.ComponentState)1 ComponentSelectionDescriptorInternal (org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal)1