Search in sources :

Example 6 with ModuleVersionSelector

use of org.gradle.api.artifacts.ModuleVersionSelector in project gradle by gradle.

the class ExternalModuleIvyDependencyDescriptorFactory method createDependencyDescriptor.

public DslOriginDependencyMetadata createDependencyDescriptor(String clientConfiguration, AttributeContainer clientAttributes, ModuleDependency dependency) {
    ExternalModuleDependency externalModuleDependency = (ExternalModuleDependency) dependency;
    boolean force = externalModuleDependency.isForce();
    boolean changing = externalModuleDependency.isChanging();
    boolean transitive = externalModuleDependency.isTransitive();
    ModuleVersionSelector requested = new DefaultModuleVersionSelector(nullToEmpty(dependency.getGroup()), nullToEmpty(dependency.getName()), nullToEmpty(dependency.getVersion()));
    ModuleComponentSelector selector = DefaultModuleComponentSelector.newSelector(requested);
    List<Exclude> excludes = convertExcludeRules(clientConfiguration, dependency.getExcludeRules());
    LocalComponentDependencyMetadata dependencyMetaData = new LocalComponentDependencyMetadata(selector, requested, clientConfiguration, clientAttributes, dependency.getTargetConfiguration(), convertArtifacts(dependency.getArtifacts()), excludes, force, changing, transitive);
    return new DslOriginDependencyMetadataWrapper(dependencyMetaData, dependency);
}
Also used : DefaultModuleVersionSelector(org.gradle.api.internal.artifacts.DefaultModuleVersionSelector) ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) DefaultModuleVersionSelector(org.gradle.api.internal.artifacts.DefaultModuleVersionSelector) Exclude(org.gradle.internal.component.model.Exclude) 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) LocalComponentDependencyMetadata(org.gradle.internal.component.model.LocalComponentDependencyMetadata)

Example 7 with ModuleVersionSelector

use of org.gradle.api.artifacts.ModuleVersionSelector in project gradle by gradle.

the class DefaultVersionedComponentChooser method selectNewestMatchingComponent.

public void selectNewestMatchingComponent(Collection<? extends ModuleComponentResolveState> versions, BuildableComponentSelectionResult result, ModuleVersionSelector requested) {
    VersionSelector requestedVersion = versionSelectorScheme.parseSelector(requested.getVersion());
    Collection<SpecRuleAction<? super ComponentSelection>> rules = componentSelectionRules.getRules();
    for (ModuleComponentResolveState candidate : sortLatestFirst(versions)) {
        MetadataProvider metadataProvider = createMetadataProvider(candidate);
        boolean versionMatches = versionMatches(requestedVersion, candidate, metadataProvider);
        if (!metadataProvider.isUsable()) {
            applyTo(metadataProvider, result);
            return;
        }
        if (!versionMatches) {
            result.notMatched(candidate.getVersion());
            continue;
        }
        ModuleComponentIdentifier candidateIdentifier = candidate.getId();
        boolean accepted = !isRejectedByRules(candidateIdentifier, rules, metadataProvider);
        if (!metadataProvider.isUsable()) {
            applyTo(metadataProvider, result);
            return;
        }
        if (accepted) {
            result.matches(candidateIdentifier);
            return;
        }
        result.rejected(candidate.getVersion());
        if (requestedVersion.matchesUniqueVersion()) {
            // Only consider one candidate
            break;
        }
    }
    result.noMatchFound();
}
Also used : SpecRuleAction(org.gradle.internal.rules.SpecRuleAction) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) ComponentSelection(org.gradle.api.artifacts.ComponentSelection) DefaultComponentSelection(org.gradle.api.internal.artifacts.DefaultComponentSelection) VersionSelector(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.strategy.VersionSelector) ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector)

Example 8 with ModuleVersionSelector

use of org.gradle.api.artifacts.ModuleVersionSelector in project gradle by gradle.

the class DynamicVersionResolver method resolve.

public void resolve(DependencyMetadata dependency, BuildableComponentIdResolveResult result) {
    ModuleVersionSelector requested = dependency.getRequested();
    LOGGER.debug("Attempting to resolve version for {} using repositories {}", requested, repositoryNames);
    List<Throwable> errors = new ArrayList<Throwable>();
    List<RepositoryResolveState> resolveStates = new ArrayList<RepositoryResolveState>();
    for (ModuleComponentRepository repository : repositories) {
        resolveStates.add(new RepositoryResolveState(dependency, repository));
    }
    final RepositoryChainModuleResolution latestResolved = findLatestModule(resolveStates, errors);
    if (latestResolved != null) {
        LOGGER.debug("Using {} from {}", latestResolved.module.getId(), latestResolved.repository);
        for (Throwable error : errors) {
            LOGGER.debug("Discarding resolve failure.", error);
        }
        result.resolved(metaDataFactory.transform(latestResolved));
        return;
    }
    if (!errors.isEmpty()) {
        result.failed(new ModuleVersionResolveException(requested, errors));
    } else {
        notFound(result, requested, resolveStates);
    }
}
Also used : ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) ArrayList(java.util.ArrayList) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException)

Example 9 with ModuleVersionSelector

use of org.gradle.api.artifacts.ModuleVersionSelector in project gradle by gradle.

the class ResolutionFailureCollector method complete.

public Set<UnresolvedDependency> complete() {
    if (failuresByRevisionId.isEmpty()) {
        ImmutableSet.of();
    }
    ImmutableSet.Builder<UnresolvedDependency> builder = ImmutableSet.builder();
    for (Map.Entry<ComponentSelector, BrokenDependency> entry : failuresByRevisionId.entrySet()) {
        Collection<List<ComponentIdentifier>> paths = DependencyGraphPathResolver.calculatePaths(entry.getValue().requiredBy, root);
        ComponentSelector key = entry.getKey();
        ModuleVersionSelector moduleVersionSelector = componentSelectorConverter.getSelector(key);
        builder.add(new DefaultUnresolvedDependency(moduleVersionSelector, entry.getValue().failure.withIncomingPaths(paths)));
    }
    return builder.build();
}
Also used : ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) ImmutableSet(com.google.common.collect.ImmutableSet) ComponentSelector(org.gradle.api.artifacts.component.ComponentSelector) UnresolvedDependency(org.gradle.api.artifacts.UnresolvedDependency) DefaultUnresolvedDependency(org.gradle.api.internal.artifacts.ivyservice.DefaultUnresolvedDependency) DefaultUnresolvedDependency(org.gradle.api.internal.artifacts.ivyservice.DefaultUnresolvedDependency) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 10 with ModuleVersionSelector

use of org.gradle.api.artifacts.ModuleVersionSelector in project gradle by gradle.

the class DefaultDependencyResolveDetails method useTarget.

@Override
public void useTarget(Object notation) {
    ModuleVersionSelector newTarget = ModuleVersionSelectorParsers.parser().parseNotation(notation);
    useVersion = null;
    useSelector = DefaultModuleComponentSelector.newSelector(newTarget);
    useComponentSelector();
}
Also used : DefaultModuleVersionSelector(org.gradle.api.internal.artifacts.DefaultModuleVersionSelector) ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector)

Aggregations

ModuleVersionSelector (org.gradle.api.artifacts.ModuleVersionSelector)18 DefaultModuleVersionSelector (org.gradle.api.internal.artifacts.DefaultModuleVersionSelector)9 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)5 DefaultModuleComponentSelector (org.gradle.internal.component.external.model.DefaultModuleComponentSelector)5 Exclude (org.gradle.internal.component.model.Exclude)4 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Map (java.util.Map)3 ComponentSelector (org.gradle.api.artifacts.component.ComponentSelector)3 ProjectComponentSelector (org.gradle.api.artifacts.component.ProjectComponentSelector)3 LinkedHashMap (java.util.LinkedHashMap)2 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)2 DefaultUnresolvedDependency (org.gradle.api.internal.artifacts.ivyservice.DefaultUnresolvedDependency)2 Artifact (org.gradle.internal.component.external.descriptor.Artifact)2 DefaultExclude (org.gradle.internal.component.external.descriptor.DefaultExclude)2 DslOriginDependencyMetadataWrapper (org.gradle.internal.component.local.model.DslOriginDependencyMetadataWrapper)2 DefaultIvyArtifactName (org.gradle.internal.component.model.DefaultIvyArtifactName)2 LocalComponentDependencyMetadata (org.gradle.internal.component.model.LocalComponentDependencyMetadata)2 ImmutableSet (com.google.common.collect.ImmutableSet)1