use of org.gradle.internal.component.model.DependencyMetadata in project gradle by gradle.
the class RealisedMavenModuleResolveMetadataSerializationHelper method writeDependencies.
@Override
protected void writeDependencies(Encoder encoder, ConfigurationMetadata configuration, Map<ExternalDependencyDescriptor, Integer> deduplicationDependencyCache) throws IOException {
List<? extends DependencyMetadata> dependencies = configuration.getDependencies();
encoder.writeSmallInt(dependencies.size());
for (DependencyMetadata dependency : dependencies) {
if (dependency instanceof ForcedDependencyMetadataWrapper) {
ForcedDependencyMetadataWrapper wrapper = (ForcedDependencyMetadataWrapper) dependency;
dependency = wrapper.unwrap();
if (wrapper.isForce()) {
encoder.writeByte(FORCED_DEPENDENCY_METADATA);
}
}
if (dependency instanceof GradleDependencyMetadata) {
encoder.writeByte(GRADLE_DEPENDENCY_METADATA);
writeDependencyMetadata(encoder, (GradleDependencyMetadata) dependency);
} else if (dependency instanceof ConfigurationBoundExternalDependencyMetadata) {
ConfigurationBoundExternalDependencyMetadata dependencyMetadata = (ConfigurationBoundExternalDependencyMetadata) dependency;
ExternalDependencyDescriptor dependencyDescriptor = dependencyMetadata.getDependencyDescriptor();
if (dependencyDescriptor instanceof MavenDependencyDescriptor) {
encoder.writeByte(MAVEN_DEPENDENCY_METADATA);
writeMavenDependency(encoder, (MavenDependencyDescriptor) dependencyDescriptor, deduplicationDependencyCache);
} else {
throw new IllegalStateException("Unknown type of dependency descriptor: " + dependencyDescriptor.getClass());
}
encoder.writeNullableString(dependency.getReason());
}
}
}
use of org.gradle.internal.component.model.DependencyMetadata in project gradle by gradle.
the class IvyDynamicResolveModuleComponentRepositoryAccess method transformDependencies.
private void transformDependencies(BuildableModuleComponentMetaDataResolveResult result) {
ModuleComponentResolveMetadata metadata = result.getMetaData();
MutableModuleComponentResolveMetadata mutableMetadata = metadata.asMutable();
List<DependencyMetadata> transformed = new ArrayList<DependencyMetadata>();
for (DependencyMetadata dependency : metadata.getDependencies()) {
transformed.add(dependency.withRequestedVersion(dependency.getDynamicConstraintVersion()));
}
mutableMetadata.setDependencies(transformed);
result.setMetadata(mutableMetadata.asImmutable());
}
use of org.gradle.internal.component.model.DependencyMetadata in project gradle by gradle.
the class DirectDependencyForcingResolver method select.
@Override
public <T extends ComponentResolutionState> void select(ConflictResolverDetails<T> details) {
Collection<? extends T> candidates = details.getCandidates();
for (NodeState configuration : root.getNodes()) {
for (EdgeState outgoingEdge : configuration.getOutgoingEdges()) {
ComponentState targetComponent = outgoingEdge.getTargetComponent();
DependencyMetadata dependencyMetadata = outgoingEdge.getDependencyMetadata();
// Will always be true because we are looking at direct dependencies only
assert dependencyMetadata instanceof LocalOriginDependencyMetadata;
if (((LocalOriginDependencyMetadata) dependencyMetadata).isForce() && candidates.contains(targetComponent)) {
targetComponent.addCause(VersionSelectionReasons.FORCED);
details.select(Cast.<T>uncheckedCast(targetComponent));
return;
}
}
}
}
use of org.gradle.internal.component.model.DependencyMetadata in project gradle by gradle.
the class ModuleResolveState method appendAttributes.
private ImmutableAttributes appendAttributes(ImmutableAttributes dependencyAttributes, SelectorState selectorState) {
try {
DependencyMetadata dependencyMetadata = selectorState.getDependencyMetadata();
boolean constraint = dependencyMetadata.isConstraint();
if (constraint) {
ComponentSelector selector = dependencyMetadata.getSelector();
ImmutableAttributes attributes = ((AttributeContainerInternal) selector.getAttributes()).asImmutable();
dependencyAttributes = attributesFactory.safeConcat(attributes, dependencyAttributes);
}
} catch (AttributeMergingException e) {
attributeMergingError = e;
}
return dependencyAttributes;
}
use of org.gradle.internal.component.model.DependencyMetadata in project gradle by gradle.
the class RealisedIvyModuleResolveMetadata method withDependencies.
private IvyModuleResolveMetadata withDependencies(Map<IvyDependencyDescriptor, IvyDependencyDescriptor> transformed) {
ImmutableList<IvyDependencyDescriptor> transformedDescriptors = ImmutableList.copyOf(transformed.values());
Set<String> configurationNames = getConfigurationNames();
Map<String, ConfigurationMetadata> transformedConfigurations = Maps.newHashMapWithExpectedSize(configurationNames.size());
for (String name : configurationNames) {
RealisedConfigurationMetadata configuration = (RealisedConfigurationMetadata) getConfiguration(name);
List<? extends DependencyMetadata> dependencies = configuration.getDependencies();
ImmutableList.Builder<ModuleDependencyMetadata> transformedConfigurationDependencies = ImmutableList.builder();
for (DependencyMetadata dependency : dependencies) {
if (dependency instanceof ConfigurationBoundExternalDependencyMetadata) {
transformedConfigurationDependencies.add(((ConfigurationBoundExternalDependencyMetadata) dependency).withDescriptor(transformed.get(((ConfigurationBoundExternalDependencyMetadata) dependency).getDependencyDescriptor())));
} else {
transformedConfigurationDependencies.add((ModuleDependencyMetadata) dependency);
}
}
transformedConfigurations.put(name, configuration.withDependencies(transformedConfigurationDependencies.build()));
}
return new RealisedIvyModuleResolveMetadata(this, transformedDescriptors, transformedConfigurations);
}
Aggregations