Search in sources :

Example 6 with DependencyMetadata

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());
        }
    }
}
Also used : ForcedDependencyMetadataWrapper(org.gradle.internal.component.external.model.ForcedDependencyMetadataWrapper) GradleDependencyMetadata(org.gradle.internal.component.external.model.GradleDependencyMetadata) ConfigurationBoundExternalDependencyMetadata(org.gradle.internal.component.external.model.ConfigurationBoundExternalDependencyMetadata) ExternalDependencyDescriptor(org.gradle.internal.component.external.model.ExternalDependencyDescriptor) GradleDependencyMetadata(org.gradle.internal.component.external.model.GradleDependencyMetadata) DependencyMetadata(org.gradle.internal.component.model.DependencyMetadata) ModuleDependencyMetadata(org.gradle.internal.component.external.model.ModuleDependencyMetadata) ConfigurationBoundExternalDependencyMetadata(org.gradle.internal.component.external.model.ConfigurationBoundExternalDependencyMetadata)

Example 7 with DependencyMetadata

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());
}
Also used : MutableModuleComponentResolveMetadata(org.gradle.internal.component.external.model.MutableModuleComponentResolveMetadata) ModuleComponentResolveMetadata(org.gradle.internal.component.external.model.ModuleComponentResolveMetadata) MutableModuleComponentResolveMetadata(org.gradle.internal.component.external.model.MutableModuleComponentResolveMetadata) ArrayList(java.util.ArrayList) DependencyMetadata(org.gradle.internal.component.model.DependencyMetadata)

Example 8 with DependencyMetadata

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;
            }
        }
    }
}
Also used : LocalOriginDependencyMetadata(org.gradle.internal.component.model.LocalOriginDependencyMetadata) DependencyMetadata(org.gradle.internal.component.model.DependencyMetadata) LocalOriginDependencyMetadata(org.gradle.internal.component.model.LocalOriginDependencyMetadata)

Example 9 with DependencyMetadata

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;
}
Also used : ImmutableAttributes(org.gradle.api.internal.attributes.ImmutableAttributes) ComponentSelector(org.gradle.api.artifacts.component.ComponentSelector) DependencyMetadata(org.gradle.internal.component.model.DependencyMetadata) ForcingDependencyMetadata(org.gradle.internal.component.model.ForcingDependencyMetadata) AttributeContainerInternal(org.gradle.api.internal.attributes.AttributeContainerInternal) AttributeMergingException(org.gradle.api.internal.attributes.AttributeMergingException)

Example 10 with DependencyMetadata

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);
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) ConfigurationBoundExternalDependencyMetadata(org.gradle.internal.component.external.model.ConfigurationBoundExternalDependencyMetadata) ModuleDependencyMetadata(org.gradle.internal.component.external.model.ModuleDependencyMetadata) ConfigurationMetadata(org.gradle.internal.component.model.ConfigurationMetadata) ModuleConfigurationMetadata(org.gradle.internal.component.model.ModuleConfigurationMetadata) RealisedConfigurationMetadata(org.gradle.internal.component.external.model.RealisedConfigurationMetadata) RealisedConfigurationMetadata(org.gradle.internal.component.external.model.RealisedConfigurationMetadata) DependencyMetadata(org.gradle.internal.component.model.DependencyMetadata) ModuleDependencyMetadata(org.gradle.internal.component.external.model.ModuleDependencyMetadata) ConfigurationBoundExternalDependencyMetadata(org.gradle.internal.component.external.model.ConfigurationBoundExternalDependencyMetadata)

Aggregations

DependencyMetadata (org.gradle.internal.component.model.DependencyMetadata)11 ConfigurationBoundExternalDependencyMetadata (org.gradle.internal.component.external.model.ConfigurationBoundExternalDependencyMetadata)3 ModuleDependencyMetadata (org.gradle.internal.component.external.model.ModuleDependencyMetadata)3 LocalFileDependencyMetadata (org.gradle.internal.component.local.model.LocalFileDependencyMetadata)3 ModuleIdentifier (org.gradle.api.artifacts.ModuleIdentifier)2 ComponentSelector (org.gradle.api.artifacts.component.ComponentSelector)2 ExternalDependencyDescriptor (org.gradle.internal.component.external.model.ExternalDependencyDescriptor)2 GradleDependencyMetadata (org.gradle.internal.component.external.model.GradleDependencyMetadata)2 RealisedConfigurationMetadata (org.gradle.internal.component.external.model.RealisedConfigurationMetadata)2 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 ModuleDependency (org.gradle.api.artifacts.ModuleDependency)1 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)1 AttributeContainerInternal (org.gradle.api.internal.attributes.AttributeContainerInternal)1 AttributeMergingException (org.gradle.api.internal.attributes.AttributeMergingException)1 ImmutableAttributes (org.gradle.api.internal.attributes.ImmutableAttributes)1 ForcedDependencyMetadataWrapper (org.gradle.internal.component.external.model.ForcedDependencyMetadataWrapper)1 ModuleComponentResolveMetadata (org.gradle.internal.component.external.model.ModuleComponentResolveMetadata)1 MutableModuleComponentResolveMetadata (org.gradle.internal.component.external.model.MutableModuleComponentResolveMetadata)1 ConfigurationMetadata (org.gradle.internal.component.model.ConfigurationMetadata)1