Search in sources :

Example 1 with DefaultConflictResolverDetails

use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.conflicts.DefaultConflictResolverDetails in project gradle by gradle.

the class ProjectDependencyForcingResolver method select.

@Override
public <T extends ComponentResolutionState> void select(ConflictResolverDetails<T> details) {
    // the collection will only be initialized if more than one project candidate is found
    Collection<T> projectCandidates = null;
    T foundProjectCandidate = null;
    // fine one or more project dependencies among conflicting modules
    for (T candidate : details.getCandidates()) {
        ComponentResolveMetadata metaData = candidate.getMetadata();
        if (metaData != null && metaData.getId() instanceof ProjectComponentIdentifier) {
            if (foundProjectCandidate == null) {
                // found the first project dependency
                foundProjectCandidate = candidate;
            } else {
                // found more than one
                if (projectCandidates == null) {
                    projectCandidates = new ArrayList<T>();
                    projectCandidates.add(foundProjectCandidate);
                }
                projectCandidates.add(candidate);
            }
        }
    }
    // let the delegate resolver select among them
    if (projectCandidates != null) {
        ConflictResolverDetails<T> projectDetails = new DefaultConflictResolverDetails<T>(Cast.<List<T>>uncheckedCast(projectCandidates));
        delegate.select(projectDetails);
        details.select(projectDetails.getSelected());
        return;
    }
    // if found only one project dependency - return it, otherwise call the next resolver
    if (foundProjectCandidate != null) {
        details.select(foundProjectCandidate);
    } else {
        delegate.select(details);
    }
}
Also used : DefaultConflictResolverDetails(org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.conflicts.DefaultConflictResolverDetails) ComponentResolveMetadata(org.gradle.internal.component.model.ComponentResolveMetadata) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier)

Aggregations

ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)1 DefaultConflictResolverDetails (org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.conflicts.DefaultConflictResolverDetails)1 ComponentResolveMetadata (org.gradle.internal.component.model.ComponentResolveMetadata)1