Search in sources :

Example 1 with DependencySubstitutionApplicator

use of org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.DependencySubstitutionApplicator in project gradle by gradle.

the class NodeState method maybeSubstitute.

/**
 * Execute any dependency substitution rules that apply to this dependency.
 *
 * This may be better done as a decorator on ConfigurationMetadata.getDependencies()
 */
static DependencyState maybeSubstitute(DependencyState dependencyState, DependencySubstitutionApplicator dependencySubstitutionApplicator) {
    DependencySubstitutionApplicator.SubstitutionResult substitutionResult = dependencySubstitutionApplicator.apply(dependencyState.getDependency());
    if (substitutionResult.hasFailure()) {
        dependencyState.failure = new ModuleVersionResolveException(dependencyState.getRequested(), substitutionResult.getFailure());
        return dependencyState;
    }
    DependencySubstitutionInternal details = substitutionResult.getResult();
    if (details != null && details.isUpdated()) {
        ArtifactSelectionDetailsInternal artifactSelectionDetails = details.getArtifactSelectionDetails();
        if (artifactSelectionDetails.isUpdated()) {
            return dependencyState.withTargetAndArtifacts(details.getTarget(), artifactSelectionDetails.getTargetSelectors(), details.getRuleDescriptors());
        }
        return dependencyState.withTarget(details.getTarget(), details.getRuleDescriptors());
    }
    return dependencyState;
}
Also used : ArtifactSelectionDetailsInternal(org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.ArtifactSelectionDetailsInternal) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException) DependencySubstitutionApplicator(org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.DependencySubstitutionApplicator) DependencySubstitutionInternal(org.gradle.api.internal.artifacts.DependencySubstitutionInternal)

Example 2 with DependencySubstitutionApplicator

use of org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.DependencySubstitutionApplicator in project gradle by gradle.

the class DefaultArtifactDependencyResolver method createDependencySubstitutionApplicator.

private DependencySubstitutionApplicator createDependencySubstitutionApplicator(ResolutionStrategyInternal resolutionStrategy) {
    Action<DependencySubstitution> rule = resolutionStrategy.getDependencySubstitutionRule();
    DependencySubstitutionApplicator applicator;
    if (Actions.<DependencySubstitution>doNothing() == rule) {
        applicator = NO_OP;
    } else {
        applicator = new CachingDependencySubstitutionApplicator(new DefaultDependencySubstitutionApplicator(componentSelectionDescriptorFactory, rule, instantiator));
    }
    return applicator;
}
Also used : DependencySubstitution(org.gradle.api.artifacts.DependencySubstitution) CachingDependencySubstitutionApplicator(org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.CachingDependencySubstitutionApplicator) DefaultDependencySubstitutionApplicator(org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.DefaultDependencySubstitutionApplicator) DependencySubstitutionApplicator(org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.DependencySubstitutionApplicator) CachingDependencySubstitutionApplicator(org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.CachingDependencySubstitutionApplicator) DefaultDependencySubstitutionApplicator(org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.DefaultDependencySubstitutionApplicator)

Example 3 with DependencySubstitutionApplicator

use of org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.DependencySubstitutionApplicator in project gradle by gradle.

the class DefaultArtifactDependencyResolver method createDependencyGraphBuilder.

private DependencyGraphBuilder createDependencyGraphBuilder(ComponentResolversChain componentSource, ResolutionStrategyInternal resolutionStrategy, GlobalDependencyResolutionRules globalRules, Spec<? super DependencyMetadata> edgeFilter, AttributesSchemaInternal attributesSchema, ModuleExclusions moduleExclusions, BuildOperationExecutor buildOperationExecutor) {
    DependencyToComponentIdResolver componentIdResolver = componentSource.getComponentIdResolver();
    ComponentMetaDataResolver componentMetaDataResolver = new ClientModuleResolver(componentSource.getComponentResolver(), dependencyDescriptorFactory);
    ResolveContextToComponentResolver requestResolver = createResolveContextConverter();
    ModuleConflictHandler conflictHandler = createModuleConflictHandler(resolutionStrategy, globalRules);
    DefaultCapabilitiesConflictHandler capabilitiesConflictHandler = createCapabilitiesConflictHandler(resolutionStrategy.getCapabilitiesResolutionRules());
    DependencySubstitutionApplicator applicator = createDependencySubstitutionApplicator(resolutionStrategy);
    return new DependencyGraphBuilder(componentIdResolver, componentMetaDataResolver, requestResolver, conflictHandler, capabilitiesConflictHandler, edgeFilter, attributesSchema, moduleExclusions, buildOperationExecutor, applicator, componentSelectorConverter, attributesFactory, versionSelectorScheme, versionComparator.asVersionComparator(), versionParser);
}
Also used : ComponentMetaDataResolver(org.gradle.internal.resolve.resolver.ComponentMetaDataResolver) ClientModuleResolver(org.gradle.api.internal.artifacts.ivyservice.clientmodule.ClientModuleResolver) ModuleConflictHandler(org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.conflicts.ModuleConflictHandler) DependencyGraphBuilder(org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder) ResolveContextToComponentResolver(org.gradle.internal.resolve.resolver.ResolveContextToComponentResolver) DefaultCapabilitiesConflictHandler(org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.conflicts.DefaultCapabilitiesConflictHandler) DefaultDependencySubstitutionApplicator(org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.DefaultDependencySubstitutionApplicator) DependencySubstitutionApplicator(org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.DependencySubstitutionApplicator) CachingDependencySubstitutionApplicator(org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.CachingDependencySubstitutionApplicator) DependencyToComponentIdResolver(org.gradle.internal.resolve.resolver.DependencyToComponentIdResolver)

Aggregations

DependencySubstitutionApplicator (org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.DependencySubstitutionApplicator)3 CachingDependencySubstitutionApplicator (org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.CachingDependencySubstitutionApplicator)2 DefaultDependencySubstitutionApplicator (org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.DefaultDependencySubstitutionApplicator)2 DependencySubstitution (org.gradle.api.artifacts.DependencySubstitution)1 DependencySubstitutionInternal (org.gradle.api.internal.artifacts.DependencySubstitutionInternal)1 ClientModuleResolver (org.gradle.api.internal.artifacts.ivyservice.clientmodule.ClientModuleResolver)1 ArtifactSelectionDetailsInternal (org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.ArtifactSelectionDetailsInternal)1 DependencyGraphBuilder (org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder)1 DefaultCapabilitiesConflictHandler (org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.conflicts.DefaultCapabilitiesConflictHandler)1 ModuleConflictHandler (org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.conflicts.ModuleConflictHandler)1 ModuleVersionResolveException (org.gradle.internal.resolve.ModuleVersionResolveException)1 ComponentMetaDataResolver (org.gradle.internal.resolve.resolver.ComponentMetaDataResolver)1 DependencyToComponentIdResolver (org.gradle.internal.resolve.resolver.DependencyToComponentIdResolver)1 ResolveContextToComponentResolver (org.gradle.internal.resolve.resolver.ResolveContextToComponentResolver)1