Search in sources :

Example 11 with ModuleComponentSelector

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

the class ConfigurationBoundExternalDependencyMetadata method withTarget.

@Override
public DependencyMetadata withTarget(ComponentSelector target) {
    if (target instanceof ModuleComponentSelector) {
        ModuleComponentSelector moduleTarget = (ModuleComponentSelector) target;
        ModuleComponentSelector newSelector = DefaultModuleComponentSelector.newSelector(moduleTarget.getModuleIdentifier(), moduleTarget.getVersionConstraint(), moduleTarget.getAttributes(), moduleTarget.getRequestedCapabilities());
        if (newSelector.equals(getSelector())) {
            return this;
        }
        return withRequested(newSelector);
    } else if (target instanceof ProjectComponentSelector) {
        ProjectComponentSelector projectTarget = (ProjectComponentSelector) target;
        return new DefaultProjectDependencyMetadata(projectTarget, this);
    } else {
        throw new IllegalArgumentException("Unexpected selector provided: " + target);
    }
}
Also used : DefaultProjectDependencyMetadata(org.gradle.internal.component.local.model.DefaultProjectDependencyMetadata) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) ProjectComponentSelector(org.gradle.api.artifacts.component.ProjectComponentSelector)

Example 12 with ModuleComponentSelector

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

the class DefaultIvyModuleResolveMetadata method withDynamicConstraintVersions.

@Override
public IvyModuleResolveMetadata withDynamicConstraintVersions() {
    List<IvyDependencyDescriptor> transformed = CollectionUtils.collect(getDependencies(), dependency -> {
        ModuleComponentSelector selector = dependency.getSelector();
        String dynamicConstraintVersion = dependency.getDynamicConstraintVersion();
        ModuleComponentSelector newSelector = DefaultModuleComponentSelector.newSelector(selector.getModuleIdentifier(), dynamicConstraintVersion);
        return dependency.withRequested(newSelector);
    });
    return this.withDependencies(transformed);
}
Also used : DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector)

Example 13 with ModuleComponentSelector

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

the class RealisedIvyModuleResolveMetadataSerializationHelper method readIvyDependency.

private IvyDependencyDescriptor readIvyDependency(Decoder decoder) throws IOException {
    ModuleComponentSelector requested = getComponentSelectorSerializer().read(decoder);
    SetMultimap<String, String> configMappings = readDependencyConfigurationMapping(decoder);
    List<Artifact> artifacts = readDependencyArtifactDescriptors(decoder);
    List<Exclude> excludes = readDependencyExcludes(decoder);
    String dynamicConstraintVersion = decoder.readString();
    boolean changing = decoder.readBoolean();
    boolean transitive = decoder.readBoolean();
    boolean optional = decoder.readBoolean();
    return new IvyDependencyDescriptor(requested, dynamicConstraintVersion, changing, transitive, optional, configMappings, artifacts, excludes);
}
Also used : Exclude(org.gradle.internal.component.model.Exclude) DefaultExclude(org.gradle.internal.component.external.descriptor.DefaultExclude) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) Artifact(org.gradle.internal.component.external.descriptor.Artifact)

Example 14 with ModuleComponentSelector

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

the class DefaultComponentSelectorConverter method getSelector.

@Override
public ModuleVersionSelector getSelector(ComponentSelector selector) {
    if (selector instanceof ModuleComponentSelector) {
        return DefaultModuleVersionSelector.newSelector((ModuleComponentSelector) selector);
    }
    if (selector instanceof ProjectComponentSelector) {
        ProjectComponentSelector projectSelector = (ProjectComponentSelector) selector;
        ProjectComponentIdentifier projectId = componentIdentifierFactory.createProjectComponentIdentifier(projectSelector);
        LocalComponentMetadata projectComponent = localComponentRegistry.getComponent(projectId);
        if (projectComponent != null) {
            ModuleVersionIdentifier moduleVersionId = projectComponent.getModuleVersionId();
            return DefaultModuleVersionSelector.newSelector(moduleVersionId.getModule(), moduleVersionId.getVersion());
        }
    }
    if (selector instanceof LibraryComponentSelector) {
        LibraryComponentSelector libraryComponentSelector = (LibraryComponentSelector) selector;
        String libraryName = GUtil.elvis(libraryComponentSelector.getLibraryName(), "");
        return DefaultModuleVersionSelector.newSelector(DefaultModuleIdentifier.newId(libraryComponentSelector.getProjectPath(), libraryName), "undefined");
    }
    return UNKNOWN_MODULE_VERSION_SELECTOR;
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) ProjectComponentSelector(org.gradle.api.artifacts.component.ProjectComponentSelector) LocalComponentMetadata(org.gradle.internal.component.local.model.LocalComponentMetadata) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier) LibraryComponentSelector(org.gradle.api.artifacts.component.LibraryComponentSelector)

Example 15 with ModuleComponentSelector

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

the class ExternalModuleIvyDependencyDescriptorFactory method createDependencyDescriptor.

@Override
public LocalOriginDependencyMetadata createDependencyDescriptor(ComponentIdentifier componentId, @Nullable String clientConfiguration, @Nullable AttributeContainer clientAttributes, ModuleDependency dependency) {
    ExternalModuleDependency externalModuleDependency = (ExternalModuleDependency) dependency;
    boolean force = externalModuleDependency.isForce();
    boolean changing = externalModuleDependency.isChanging();
    boolean transitive = externalModuleDependency.isTransitive();
    ModuleComponentSelector selector = DefaultModuleComponentSelector.newSelector(DefaultModuleIdentifier.newId(nullToEmpty(dependency.getGroup()), nullToEmpty(dependency.getName())), ((VersionConstraintInternal) externalModuleDependency.getVersionConstraint()).asImmutable(), dependency.getAttributes(), dependency.getRequestedCapabilities());
    List<ExcludeMetadata> excludes = convertExcludeRules(dependency.getExcludeRules());
    LocalComponentDependencyMetadata dependencyMetaData = new LocalComponentDependencyMetadata(componentId, selector, clientConfiguration, clientAttributes, dependency.getAttributes(), dependency.getTargetConfiguration(), convertArtifacts(dependency.getArtifacts()), excludes, force, changing, transitive, false, dependency.isEndorsingStrictVersions(), dependency.getReason());
    return new DslOriginDependencyMetadataWrapper(dependencyMetaData, dependency);
}
Also used : DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DslOriginDependencyMetadataWrapper(org.gradle.internal.component.local.model.DslOriginDependencyMetadataWrapper) ExternalModuleDependency(org.gradle.api.artifacts.ExternalModuleDependency) ExcludeMetadata(org.gradle.internal.component.model.ExcludeMetadata) LocalComponentDependencyMetadata(org.gradle.internal.component.model.LocalComponentDependencyMetadata)

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