Search in sources :

Example 16 with ComponentSelector

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

the class DefaultDependencySubstitutions method substitute.

@Override
public Substitution substitute(final ComponentSelector substituted) {
    return new Substitution() {

        ComponentSelectionDescriptorInternal substitutionReason = (ComponentSelectionDescriptorInternal) reason;

        @Override
        public Substitution because(String description) {
            substitutionReason = substitutionReason.withReason(description);
            return this;
        }

        @Override
        public void with(ComponentSelector substitute) {
            DefaultDependencySubstitution.validateTarget(substitute);
            if (substituted instanceof UnversionedModuleComponentSelector) {
                final ModuleIdentifier moduleId = ((UnversionedModuleComponentSelector) substituted).getModuleIdentifier();
                all(new ModuleMatchDependencySubstitutionAction(substitutionReason, moduleId, substitute));
            } else {
                all(new ExactMatchDependencySubstitutionAction(substitutionReason, substituted, substitute));
            }
        }
    };
}
Also used : DependencySubstitution(org.gradle.api.artifacts.DependencySubstitution) ComponentSelector(org.gradle.api.artifacts.component.ComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) ProjectComponentSelector(org.gradle.api.artifacts.component.ProjectComponentSelector) DefaultProjectComponentSelector(org.gradle.internal.component.local.model.DefaultProjectComponentSelector) ComponentSelectionDescriptorInternal(org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Example 17 with ComponentSelector

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

the class RepositoryChainDependencyToComponentIdResolver method resolve.

public void resolve(DependencyMetadata dependency, ResolvedVersionConstraint resolvedVersionConstraint, BuildableComponentIdResolveResult result) {
    ComponentSelector componentSelector = dependency.getSelector();
    if (componentSelector instanceof ModuleComponentSelector) {
        ModuleComponentSelector module = (ModuleComponentSelector) componentSelector;
        if (resolvedVersionConstraint == null) {
            // TODO:DAZ This shouldn't be required, but `ExternalResourceResolverDescriptorParseContext` does not provide a resolved constraint
            VersionConstraint raw = module.getVersionConstraint();
            resolvedVersionConstraint = new DefaultResolvedVersionConstraint(raw, versionSelectorScheme);
        }
        VersionSelector preferredSelector = resolvedVersionConstraint.getPreferredSelector();
        if (preferredSelector.isDynamic()) {
            dynamicRevisionResolver.resolve(toModuleDependencyMetadata(dependency), preferredSelector, resolvedVersionConstraint.getRejectedSelector(), result);
        } else {
            String version = resolvedVersionConstraint.getPreferredVersion();
            ModuleComponentIdentifier id = new DefaultModuleComponentIdentifier(module.getGroup(), module.getModule(), version);
            ModuleVersionIdentifier mvId = moduleIdentifierFactory.moduleWithVersion(module.getGroup(), module.getModule(), version);
            result.resolved(id, mvId);
        }
    }
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) DefaultResolvedVersionConstraint(org.gradle.api.internal.artifacts.dependencies.DefaultResolvedVersionConstraint) VersionConstraint(org.gradle.api.artifacts.VersionConstraint) ResolvedVersionConstraint(org.gradle.api.internal.artifacts.ResolvedVersionConstraint) ComponentSelector(org.gradle.api.artifacts.component.ComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DefaultResolvedVersionConstraint(org.gradle.api.internal.artifacts.dependencies.DefaultResolvedVersionConstraint) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) DefaultModuleComponentIdentifier(org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier) DefaultModuleComponentIdentifier(org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier) VersionSelector(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.strategy.VersionSelector)

Example 18 with ComponentSelector

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

the class ProjectIvyDependencyDescriptorFactory method createDependencyDescriptor.

public LocalOriginDependencyMetadata createDependencyDescriptor(ComponentIdentifier componentId, String clientConfiguration, AttributeContainer clientAttributes, ModuleDependency dependency) {
    ProjectDependencyInternal projectDependency = (ProjectDependencyInternal) dependency;
    projectDependency.beforeResolved();
    ComponentSelector selector = DefaultProjectComponentSelector.newSelector(projectDependency.getDependencyProject());
    List<ExcludeMetadata> excludes = convertExcludeRules(clientConfiguration, dependency.getExcludeRules());
    LocalComponentDependencyMetadata dependencyMetaData = new LocalComponentDependencyMetadata(componentId, selector, clientConfiguration, clientAttributes, projectDependency.getTargetConfiguration(), convertArtifacts(dependency.getArtifacts()), excludes, false, false, dependency.isTransitive(), false, dependency.getReason());
    return new DslOriginDependencyMetadataWrapper(dependencyMetaData, dependency);
}
Also used : ProjectDependencyInternal(org.gradle.api.internal.artifacts.dependencies.ProjectDependencyInternal) ComponentSelector(org.gradle.api.artifacts.component.ComponentSelector) DefaultProjectComponentSelector(org.gradle.internal.component.local.model.DefaultProjectComponentSelector) DslOriginDependencyMetadataWrapper(org.gradle.internal.component.local.model.DslOriginDependencyMetadataWrapper) ExcludeMetadata(org.gradle.internal.component.model.ExcludeMetadata) LocalComponentDependencyMetadata(org.gradle.internal.component.model.LocalComponentDependencyMetadata)

Example 19 with ComponentSelector

use of org.gradle.api.artifacts.component.ComponentSelector 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.getVersionConstraint().getPreferredVersion();
        return requestedCandidate.contains(stringNotation);
    }
    return false;
}
Also used : ComponentSelector(org.gradle.api.artifacts.component.ComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector)

Example 20 with ComponentSelector

use of org.gradle.api.artifacts.component.ComponentSelector 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()) && !requestedSelector.getVersionConstraint().equals(attemptedSelector.getVersionConstraint())) {
            return requested.getDisplayName() + " -> " + ((ModuleComponentSelector) attempted).getVersionConstraint().getPreferredVersion();
        }
    }
    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)

Aggregations

ComponentSelector (org.gradle.api.artifacts.component.ComponentSelector)21 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)9 UnresolvedDependencyResult (org.gradle.api.artifacts.result.UnresolvedDependencyResult)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)4 DefaultProjectComponentSelector (org.gradle.internal.component.local.model.DefaultProjectComponentSelector)4 File (java.io.File)3 ModuleVersionSelector (org.gradle.api.artifacts.ModuleVersionSelector)3 DependencyResult (org.gradle.api.artifacts.result.DependencyResult)3 ResolvedDependencyResult (org.gradle.api.artifacts.result.ResolvedDependencyResult)3 DefaultModuleComponentSelector (org.gradle.internal.component.external.model.DefaultModuleComponentSelector)3 JarDependency (com.android.builder.dependency.JarDependency)2 LibraryDependency (com.android.builder.dependency.LibraryDependency)2 MavenCoordinates (com.android.builder.model.MavenCoordinates)2 ImmutableList (com.google.common.collect.ImmutableList)2 HashSet (java.util.HashSet)2 UnresolvedDependency (org.gradle.api.artifacts.UnresolvedDependency)2 ComponentIdentifier (org.gradle.api.artifacts.component.ComponentIdentifier)2 ModuleComponentIdentifier (org.gradle.api.artifacts.component.ModuleComponentIdentifier)2