use of org.gradle.internal.component.model.ComponentResolveMetadata in project gradle by gradle.
the class LatestModuleConflictResolver method select.
@Override
public <T extends ComponentResolutionState> void select(ConflictResolverDetails<T> details) {
// Find the candidates with the highest base version
Version baseVersion = null;
Map<Version, T> matches = new LinkedHashMap<Version, T>();
for (T candidate : details.getCandidates()) {
Version version = VersionParser.INSTANCE.transform(candidate.getVersion());
if (baseVersion == null || versionComparator.compare(version.getBaseVersion(), baseVersion) > 0) {
matches.clear();
baseVersion = version.getBaseVersion();
matches.put(version, candidate);
} else if (version.getBaseVersion().equals(baseVersion)) {
matches.put(version, candidate);
}
}
if (matches.size() == 1) {
details.select(matches.values().iterator().next());
return;
}
// Work backwards from highest version, return the first candidate with qualified version and release status, or candidate with unqualified version
List<Version> sorted = new ArrayList<Version>(matches.keySet());
Collections.sort(sorted, Collections.reverseOrder(versionComparator));
for (Version version : sorted) {
T component = matches.get(version);
if (!version.isQualified()) {
details.select(component);
return;
}
ComponentResolveMetadata metaData = component.getMetadata();
if (metaData != null && "release".equals(metaData.getStatus())) {
details.select(component);
return;
}
}
// Nothing - just return the highest version
details.select(matches.get(sorted.get(0)));
}
use of org.gradle.internal.component.model.ComponentResolveMetadata in project gradle by gradle.
the class RepositoryChainArtifactResolver method resolveArtifactsWithType.
@Override
public void resolveArtifactsWithType(ComponentResolveMetadata component, ArtifactType artifactType, BuildableArtifactSetResolveResult result) {
ModuleComponentRepository sourceRepository = findSourceRepository(component.getSource());
ComponentResolveMetadata unpackedComponent = unpackSource(component);
// First try to determine the artifacts locally before going remote
sourceRepository.getLocalAccess().resolveArtifactsWithType(unpackedComponent, artifactType, result);
if (!result.hasResult()) {
sourceRepository.getRemoteAccess().resolveArtifactsWithType(unpackedComponent, artifactType, result);
}
}
use of org.gradle.internal.component.model.ComponentResolveMetadata in project gradle by gradle.
the class EdgeState method calculateTargetConfigurations.
private void calculateTargetConfigurations() {
targetNodes.clear();
targetNodeSelectionFailure = null;
ComponentResolveMetadata targetModuleVersion = targetModuleRevision.getMetadata();
if (targetModuleVersion == null) {
// Broken version
return;
}
ImmutableAttributes attributes = resolveState.getRoot().getMetadata().getAttributes();
List<ConfigurationMetadata> targetConfigurations;
try {
targetConfigurations = dependencyMetadata.selectConfigurations(attributes, targetModuleVersion, resolveState.getAttributesSchema());
} catch (Throwable t) {
// Failure to select the target variant/configurations from this component, given the dependency attributes/metadata.
targetNodeSelectionFailure = new ModuleVersionResolveException(dependencyState.getRequested(), t);
return;
}
for (ConfigurationMetadata targetConfiguration : targetConfigurations) {
NodeState targetNodeState = resolveState.getNode(targetModuleRevision, targetConfiguration);
this.targetNodes.add(targetNodeState);
}
}
use of org.gradle.internal.component.model.ComponentResolveMetadata in project gradle by gradle.
the class DefaultArtifactResolutionQuery method buildComponentResult.
private ComponentArtifactsResult buildComponentResult(ComponentIdentifier componentId, ComponentMetaDataResolver componentMetaDataResolver, ArtifactResolver artifactResolver) {
BuildableComponentResolveResult moduleResolveResult = new DefaultBuildableComponentResolveResult();
componentMetaDataResolver.resolve(componentId, new DefaultComponentOverrideMetadata(), moduleResolveResult);
ComponentResolveMetadata component = moduleResolveResult.getMetadata();
DefaultComponentArtifactsResult componentResult = new DefaultComponentArtifactsResult(component.getId());
for (Class<? extends Artifact> artifactType : artifactTypes) {
addArtifacts(componentResult, artifactType, component, artifactResolver);
}
return componentResult;
}
use of org.gradle.internal.component.model.ComponentResolveMetadata 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);
}
}
Aggregations