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 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);
}
}
use of org.gradle.internal.component.model.ComponentResolveMetadata in project gradle by gradle.
the class NodeState method addPlatformEdges.
private void addPlatformEdges(Collection<EdgeState> discoveredEdges, ModuleComponentIdentifier platformComponentIdentifier, ModuleComponentSelector platformSelector) {
PotentialEdge potentialEdge = PotentialEdge.of(resolveState, this, platformComponentIdentifier, platformSelector, platformComponentIdentifier);
ComponentResolveMetadata metadata = potentialEdge.metadata;
VirtualPlatformState virtualPlatformState = null;
if (metadata == null || metadata instanceof LenientPlatformResolveMetadata) {
virtualPlatformState = potentialEdge.component.getModule().getPlatformState();
virtualPlatformState.participatingModule(component.getModule());
}
if (metadata == null) {
// the platform doesn't exist, so we're building a lenient one
metadata = new LenientPlatformResolveMetadata(platformComponentIdentifier, potentialEdge.toModuleVersionId, virtualPlatformState, this, resolveState);
potentialEdge.component.setMetadata(metadata);
// And now let's make sure we do not have another version of that virtual platform missing its metadata
potentialEdge.component.getModule().maybeCreateVirtualMetadata(resolveState);
}
if (virtualEdges == null) {
virtualEdges = Lists.newArrayList();
}
EdgeState edge = potentialEdge.edge;
virtualEdges.add(edge);
edge.markUsed();
discoveredEdges.add(edge);
edge.getSelector().use(false);
}
use of org.gradle.internal.component.model.ComponentResolveMetadata in project gradle by gradle.
the class EdgeState method calculateTargetConfigurations.
private void calculateTargetConfigurations(ComponentState targetComponent) {
ComponentResolveMetadata targetModuleVersion = targetComponent.getMetadata();
targetNodes.clear();
targetNodeSelectionFailure = null;
if (targetModuleVersion == null) {
targetComponent.getModule().getPlatformState().addOrphanEdge(this);
// Broken version
return;
}
if (isConstraint && !isVirtualDependency()) {
List<NodeState> nodes = targetComponent.getNodes();
for (NodeState node : nodes) {
if (node.isSelected()) {
targetNodes.add(node);
}
}
if (targetNodes.isEmpty()) {
// There is a chance we could not attach target configurations previously
List<EdgeState> unattachedDependencies = targetComponent.getModule().getUnattachedDependencies();
if (!unattachedDependencies.isEmpty()) {
for (EdgeState otherEdge : unattachedDependencies) {
if (otherEdge != this && !otherEdge.isConstraint()) {
otherEdge.attachToTargetConfigurations();
if (otherEdge.targetNodeSelectionFailure != null) {
// Copy selection failure
this.targetNodeSelectionFailure = otherEdge.targetNodeSelectionFailure;
return;
}
break;
}
}
}
for (NodeState node : nodes) {
if (node.isSelected()) {
targetNodes.add(node);
}
}
}
return;
}
List<ConfigurationMetadata> targetConfigurations;
try {
ImmutableAttributes attributes = resolveState.getRoot().getMetadata().getAttributes();
attributes = resolveState.getAttributesFactory().concat(attributes, safeGetAttributes());
targetConfigurations = dependencyMetadata.selectConfigurations(attributes, targetModuleVersion, resolveState.getAttributesSchema(), dependencyState.getDependency().getSelector().getRequestedCapabilities());
} catch (AttributeMergingException mergeError) {
targetNodeSelectionFailure = new ModuleVersionResolveException(dependencyState.getRequested(), () -> {
Attribute<?> attribute = mergeError.getAttribute();
Object constraintValue = mergeError.getLeftValue();
Object dependencyValue = mergeError.getRightValue();
return "Inconsistency between attributes of a constraint and a dependency, on attribute '" + attribute + "' : dependency requires '" + dependencyValue + "' while constraint required '" + constraintValue + "'";
});
return;
} catch (Exception 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(targetComponent, 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, DefaultComponentOverrideMetadata.EMPTY, moduleResolveResult);
ComponentResolveMetadata component = moduleResolveResult.getMetadata();
DefaultComponentArtifactsResult componentResult = new DefaultComponentArtifactsResult(component.getId());
for (Class<? extends Artifact> artifactType : artifactTypes) {
addArtifacts(componentResult, artifactType, component, artifactResolver);
}
return componentResult;
}
Aggregations