use of org.gradle.internal.resolve.ModuleVersionResolveException in project gradle by gradle.
the class ProjectDependencyResolver method resolve.
@Override
public void resolve(DependencyMetadata dependency, VersionSelector acceptor, @Nullable VersionSelector rejector, BuildableComponentIdResolveResult result) {
if (dependency.getSelector() instanceof ProjectComponentSelector) {
ProjectComponentSelector selector = (ProjectComponentSelector) dependency.getSelector();
ProjectComponentIdentifier projectId = componentIdentifierFactory.createProjectComponentIdentifier(selector);
LocalComponentMetadata componentMetaData = localComponentRegistry.getComponent(projectId);
if (componentMetaData == null) {
result.failed(new ModuleVersionResolveException(selector, () -> projectId + " not found."));
} else {
if (rejector != null && rejector.accept(componentMetaData.getModuleVersionId().getVersion())) {
result.rejected(projectId, componentMetaData.getModuleVersionId());
} else {
result.resolved(componentMetaData);
}
}
}
}
use of org.gradle.internal.resolve.ModuleVersionResolveException in project gradle by gradle.
the class ProjectDependencyResolver method resolve.
@Override
public void resolve(ComponentIdentifier identifier, ComponentOverrideMetadata componentOverrideMetadata, final BuildableComponentResolveResult result) {
if (isProjectModule(identifier)) {
ProjectComponentIdentifier projectId = (ProjectComponentIdentifier) identifier;
LocalComponentMetadata componentMetaData = localComponentRegistry.getComponent(projectId);
if (componentMetaData == null) {
result.failed(new ModuleVersionResolveException(DefaultProjectComponentSelector.newSelector(projectId), () -> projectId + " not found."));
} else {
result.resolved(componentMetaData);
}
}
}
use of org.gradle.internal.resolve.ModuleVersionResolveException in project gradle by gradle.
the class EdgeState method getFailure.
@Override
public ModuleVersionResolveException getFailure() {
if (targetNodeSelectionFailure != null) {
return targetNodeSelectionFailure;
}
ModuleVersionResolveException selectorFailure = selector.getFailure();
if (selectorFailure != null) {
return selectorFailure;
}
ComponentState selectedComponent = getSelectedComponent();
if (selectedComponent == null) {
ModuleSelectors<SelectorState> selectors = selector.getTargetModule().getSelectors();
for (SelectorState state : selectors) {
selectorFailure = state.getFailure();
if (selectorFailure != null) {
return selectorFailure;
}
}
throw new IllegalStateException("Expected to find a selector with a failure but none was found");
}
return selectedComponent.getMetadataResolveFailure();
}
use of org.gradle.internal.resolve.ModuleVersionResolveException 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.resolve.ModuleVersionResolveException in project gradle by gradle.
the class DependencyGraphBuilder method markDeniedDynamicVersions.
private void markDeniedDynamicVersions(ComponentState cs) {
for (NodeState node : cs.getNodes()) {
List<EdgeState> incomingEdges = node.getIncomingEdges();
for (EdgeState incomingEdge : incomingEdges) {
ComponentSelector selector = incomingEdge.getSelector().getSelector();
incomingEdge.failWith(new ModuleVersionResolveException(selector, () -> String.format("Could not resolve %s: Resolution strategy disallows usage of dynamic versions", selector)));
}
}
}
Aggregations