Search in sources :

Example 36 with ModuleComponentSelector

use of org.gradle.api.artifacts.component.ModuleComponentSelector in project gradle by gradle.

the class AbstractDependencyMetadataAdapter method attributes.

@Override
public T attributes(Action<? super AttributeContainer> configureAction) {
    ModuleComponentSelector selector = getOriginalMetadata().getSelector();
    AttributeContainerInternal attributes = attributesFactory.mutable((AttributeContainerInternal) selector.getAttributes());
    configureAction.execute(attributes);
    ModuleComponentSelector target = DefaultModuleComponentSelector.newSelector(selector.getModuleIdentifier(), selector.getVersionConstraint(), attributes.asImmutable(), selector.getRequestedCapabilities());
    ModuleDependencyMetadata metadata = (ModuleDependencyMetadata) getOriginalMetadata().withTarget(target);
    updateMetadata(metadata);
    return Cast.uncheckedCast(this);
}
Also used : DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) ModuleDependencyMetadata(org.gradle.internal.component.external.model.ModuleDependencyMetadata) AttributeContainerInternal(org.gradle.api.internal.attributes.AttributeContainerInternal)

Example 37 with ModuleComponentSelector

use of org.gradle.api.artifacts.component.ModuleComponentSelector in project gradle by gradle.

the class AttributeDesugaring method desugarSelector.

public ComponentSelector desugarSelector(ComponentSelector selector) {
    if (selector instanceof ModuleComponentSelector) {
        ModuleComponentSelector module = (ModuleComponentSelector) selector;
        AttributeContainer moduleAttributes = module.getAttributes();
        if (!moduleAttributes.isEmpty()) {
            ImmutableAttributes attributes = ((AttributeContainerInternal) moduleAttributes).asImmutable();
            return DefaultModuleComponentSelector.newSelector(module.getModuleIdentifier(), module.getVersionConstraint(), desugar(attributes), module.getRequestedCapabilities());
        }
    }
    if (selector instanceof DefaultProjectComponentSelector) {
        DefaultProjectComponentSelector project = (DefaultProjectComponentSelector) selector;
        AttributeContainer projectAttributes = project.getAttributes();
        if (!projectAttributes.isEmpty()) {
            ImmutableAttributes attributes = ((AttributeContainerInternal) projectAttributes).asImmutable();
            return new DefaultProjectComponentSelector(project.getBuildIdentifier(), project.getIdentityPath(), project.projectPath(), project.getProjectName(), desugar(attributes), project.getRequestedCapabilities());
        }
    }
    return selector;
}
Also used : DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DefaultProjectComponentSelector(org.gradle.internal.component.local.model.DefaultProjectComponentSelector) AttributeContainer(org.gradle.api.attributes.AttributeContainer)

Example 38 with ModuleComponentSelector

use of org.gradle.api.artifacts.component.ModuleComponentSelector in project gradle by gradle.

the class AbstractRealisedModuleResolveMetadataSerializationHelper method readDependencyMetadata.

protected GradleDependencyMetadata readDependencyMetadata(Decoder decoder) throws IOException {
    ModuleComponentSelector selector = componentSelectorSerializer.read(decoder);
    List<ExcludeMetadata> excludes = readMavenExcludes(decoder);
    boolean constraint = decoder.readBoolean();
    boolean endorsing = decoder.readBoolean();
    boolean force = decoder.readBoolean();
    String reason = decoder.readNullableString();
    IvyArtifactName artifact = readNullableArtifact(decoder);
    return new GradleDependencyMetadata(selector, excludes, constraint, endorsing, reason, force, artifact);
}
Also used : ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) ExcludeMetadata(org.gradle.internal.component.model.ExcludeMetadata)

Example 39 with ModuleComponentSelector

use of org.gradle.api.artifacts.component.ModuleComponentSelector in project gradle by gradle.

the class ModuleDependencyMetadataWrapper method withRequestedVersion.

@Override
public ModuleDependencyMetadata withRequestedVersion(VersionConstraint requestedVersion) {
    ModuleComponentSelector selector = getSelector();
    ModuleComponentSelector newSelector = DefaultModuleComponentSelector.newSelector(selector.getModuleIdentifier(), requestedVersion, selector.getAttributes(), selector.getRequestedCapabilities());
    return new ModuleDependencyMetadataWrapper(delegate.withTarget(newSelector));
}
Also used : ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector)

Example 40 with ModuleComponentSelector

use of org.gradle.api.artifacts.component.ModuleComponentSelector in project gradle by gradle.

the class ConfigurationBoundExternalDependencyMetadata method withRequestedVersion.

@Override
public ModuleDependencyMetadata withRequestedVersion(VersionConstraint requestedVersion) {
    ModuleComponentSelector selector = getSelector();
    if (requestedVersion.equals(selector.getVersionConstraint())) {
        return this;
    }
    ModuleComponentSelector newSelector = DefaultModuleComponentSelector.newSelector(selector.getModuleIdentifier(), requestedVersion, selector.getAttributes(), selector.getRequestedCapabilities());
    return withRequested(newSelector);
}
Also used : ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector)

Aggregations

ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)46 DefaultModuleComponentSelector (org.gradle.internal.component.external.model.DefaultModuleComponentSelector)21 ComponentSelector (org.gradle.api.artifacts.component.ComponentSelector)10 ProjectComponentSelector (org.gradle.api.artifacts.component.ProjectComponentSelector)9 DefaultImmutableVersionConstraint (org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint)8 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)7 ExcludeMetadata (org.gradle.internal.component.model.ExcludeMetadata)6 ModuleIdentifier (org.gradle.api.artifacts.ModuleIdentifier)5 ModuleVersionSelector (org.gradle.api.artifacts.ModuleVersionSelector)5 ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)5 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)5 ModuleVersionResolveException (org.gradle.internal.resolve.ModuleVersionResolveException)5 ModuleComponentIdentifier (org.gradle.api.artifacts.component.ModuleComponentIdentifier)4 DefaultModuleVersionSelector (org.gradle.api.internal.artifacts.DefaultModuleVersionSelector)4 DefaultExclude (org.gradle.internal.component.external.descriptor.DefaultExclude)4 DefaultProjectComponentSelector (org.gradle.internal.component.local.model.DefaultProjectComponentSelector)4 ArrayList (java.util.ArrayList)3 ExternalModuleDependency (org.gradle.api.artifacts.ExternalModuleDependency)3 VersionConstraint (org.gradle.api.artifacts.VersionConstraint)3 MavenScope (org.gradle.internal.component.external.descriptor.MavenScope)3