Search in sources :

Example 41 with ModuleComponentSelector

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

the class RealisedIvyModuleResolveMetadata method withDynamicConstraintVersions.

@Override
public IvyModuleResolveMetadata withDynamicConstraintVersions() {
    ImmutableList<IvyDependencyDescriptor> descriptors = getDependencies();
    if (descriptors.isEmpty()) {
        return this;
    }
    Map<IvyDependencyDescriptor, IvyDependencyDescriptor> transformedDescriptors = Maps.newHashMapWithExpectedSize(descriptors.size());
    for (IvyDependencyDescriptor dependency : descriptors) {
        ModuleComponentSelector selector = dependency.getSelector();
        String dynamicConstraintVersion = dependency.getDynamicConstraintVersion();
        ModuleComponentSelector newSelector = DefaultModuleComponentSelector.newSelector(selector.getModuleIdentifier(), dynamicConstraintVersion);
        transformedDescriptors.put(dependency, dependency.withRequested(newSelector));
    }
    return this.withDependencies(transformedDescriptors);
}
Also used : ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector)

Example 42 with ModuleComponentSelector

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

the class LazyToRealisedModuleComponentResolveMetadataHelper method convertDependencies.

private static List<GradleDependencyMetadata> convertDependencies(List<? extends ComponentVariant.Dependency> dependencies, List<? extends ComponentVariant.DependencyConstraint> dependencyConstraints, boolean force) {
    List<GradleDependencyMetadata> result = new ArrayList<>(dependencies.size());
    for (ComponentVariant.Dependency dependency : dependencies) {
        ModuleComponentSelector selector = DefaultModuleComponentSelector.newSelector(DefaultModuleIdentifier.newId(dependency.getGroup(), dependency.getModule()), dependency.getVersionConstraint(), dependency.getAttributes(), dependency.getRequestedCapabilities());
        List<ExcludeMetadata> excludes = dependency.getExcludes();
        result.add(new GradleDependencyMetadata(selector, excludes, false, dependency.isEndorsingStrictVersions(), dependency.getReason(), force, dependency.getDependencyArtifact()));
    }
    for (ComponentVariant.DependencyConstraint dependencyConstraint : dependencyConstraints) {
        result.add(new GradleDependencyMetadata(DefaultModuleComponentSelector.newSelector(DefaultModuleIdentifier.newId(dependencyConstraint.getGroup(), dependencyConstraint.getModule()), dependencyConstraint.getVersionConstraint(), dependencyConstraint.getAttributes(), ImmutableList.of()), Collections.emptyList(), true, false, dependencyConstraint.getReason(), force, null));
    }
    return result;
}
Also used : ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) ArrayList(java.util.ArrayList) ExcludeMetadata(org.gradle.internal.component.model.ExcludeMetadata)

Example 43 with ModuleComponentSelector

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

the class RealisedMavenModuleResolveMetadataSerializationHelper method readMavenDependency.

private MavenDependencyDescriptor readMavenDependency(Decoder decoder, Map<Integer, MavenDependencyDescriptor> deduplicationDependencyCache) throws IOException {
    int mapping = decoder.readSmallInt();
    if (mapping == deduplicationDependencyCache.size()) {
        ModuleComponentSelector requested = getComponentSelectorSerializer().read(decoder);
        IvyArtifactName artifactName = readNullableArtifact(decoder);
        List<ExcludeMetadata> mavenExcludes = readMavenExcludes(decoder);
        MavenScope scope = MavenScope.values()[decoder.readSmallInt()];
        MavenDependencyType type = MavenDependencyType.values()[decoder.readSmallInt()];
        MavenDependencyDescriptor mavenDependencyDescriptor = new MavenDependencyDescriptor(scope, type, requested, artifactName, mavenExcludes);
        deduplicationDependencyCache.put(mapping, mavenDependencyDescriptor);
        return mavenDependencyDescriptor;
    } else {
        MavenDependencyDescriptor mavenDependencyDescriptor = deduplicationDependencyCache.get(mapping);
        assert mavenDependencyDescriptor != null;
        return mavenDependencyDescriptor;
    }
}
Also used : MavenScope(org.gradle.internal.component.external.descriptor.MavenScope) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) ExcludeMetadata(org.gradle.internal.component.model.ExcludeMetadata)

Example 44 with ModuleComponentSelector

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

the class RenderableUnresolvedDependencyResult method getName.

@Override
public String getName() {
    ComponentSelector requested = dependency.getRequested();
    ComponentSelector attempted = dependency.getAttempted();
    if (requested.equals(attempted)) {
        return requested.getDisplayName();
    }
    if (requested instanceof ModuleComponentSelector && attempted instanceof ModuleComponentSelector) {
        ModuleComponentSelector requestedSelector = (ModuleComponentSelector) requested;
        ModuleComponentSelector attemptedSelector = (ModuleComponentSelector) attempted;
        if (requestedSelector.getGroup().equals(attemptedSelector.getGroup()) && requestedSelector.getModule().equals(attemptedSelector.getModule())) {
            return requested.getDisplayName() + " -> " + attemptedSelector.getVersionConstraint().getDisplayName();
        }
    }
    return requested.getDisplayName() + " -> " + attempted.getDisplayName();
}
Also used : ComponentSelector(org.gradle.api.artifacts.component.ComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector)

Example 45 with ModuleComponentSelector

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

the class DependencyResultSpec method matchesRequested.

private boolean matchesRequested(DependencyResult candidate) {
    ComponentSelector requested = candidate.getRequested();
    if (requested instanceof ModuleComponentSelector) {
        ModuleComponentSelector requestedModule = (ModuleComponentSelector) requested;
        String requestedCandidate = requestedModule.getGroup() + ":" + requestedModule.getModule() + ":" + requestedModule.getVersion();
        return requestedCandidate.contains(stringNotation);
    }
    if (requested instanceof ProjectComponentSelector) {
        ProjectComponentSelector project = (ProjectComponentSelector) requested;
        String requestedCandidate = project.getProjectPath();
        return requestedCandidate.contains(stringNotation);
    }
    return false;
}
Also used : ComponentSelector(org.gradle.api.artifacts.component.ComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) ProjectComponentSelector(org.gradle.api.artifacts.component.ProjectComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) ProjectComponentSelector(org.gradle.api.artifacts.component.ProjectComponentSelector)

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