Search in sources :

Example 1 with ComponentSelectionDescriptorInternal

use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal in project gradle by gradle.

the class DefaultDependencyResolveDetails method complete.

public void complete() {
    if (!dirty) {
        return;
    }
    ComponentSelectionDescriptorInternal selectionReason = selectionReason();
    if (useSelector != null) {
        delegate.useTarget(useSelector, selectionReason);
    } else if (useVersion != null) {
        if (delegate.getTarget() instanceof ModuleComponentSelector) {
            ModuleComponentSelector target = (ModuleComponentSelector) delegate.getTarget();
            if (!useVersion.equals(target.getVersionConstraint())) {
                delegate.useTarget(DefaultModuleComponentSelector.newSelector(target.getModuleIdentifier(), useVersion, target.getAttributes(), target.getRequestedCapabilities()), selectionReason);
            } else {
                // Still 'updated' with reason when version remains the same.
                delegate.useTarget(delegate.getTarget(), selectionReason);
            }
        } else {
            // If the current target is a project component, it must be unmodified from the requested
            ModuleComponentSelector newTarget = DefaultModuleComponentSelector.newSelector(DefaultModuleIdentifier.newId(requested.getGroup(), requested.getName()), useVersion);
            delegate.useTarget(newTarget, selectionReason);
        }
    }
    delegate.artifactSelection(artifactSelectionAction);
    dirty = false;
}
Also used : DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) ComponentSelectionDescriptorInternal(org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal)

Example 2 with ComponentSelectionDescriptorInternal

use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal in project gradle by gradle.

the class ComponentState method getSelectionReason.

@Override
public ComponentSelectionReason getSelectionReason() {
    if (root) {
        return ComponentSelectionReasons.root();
    }
    if (cachedReason != null) {
        return cachedReason;
    }
    ComponentSelectionReasonInternal reason = ComponentSelectionReasons.empty();
    for (final SelectorState selectorState : module.getSelectors()) {
        if (selectorState.getFailure() == null) {
            selectorState.addReasonsForSelector(reason);
        }
    }
    for (ComponentSelectionDescriptorInternal selectionCause : VersionConflictResolutionDetails.mergeCauses(selectionCauses)) {
        reason.addCause(selectionCause);
    }
    cachedReason = reason;
    return reason;
}
Also used : ComponentSelectionDescriptorInternal(org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal) ComponentSelectionReasonInternal(org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionReasonInternal)

Example 3 with ComponentSelectionDescriptorInternal

use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal in project gradle by gradle.

the class SelectorState method select.

public void select(ComponentState selected) {
    selected.selectedBy(this);
    ComponentSelectionDescriptorInternal selectionDescriptor = selectionDescriptionForDependency(dependencyMetadata);
    selected.addCause(selectionDescriptor);
    if (dependencyState.getRuleDescriptor() != null) {
        selected.addCause(dependencyState.getRuleDescriptor());
    }
    // We should never select a component for a different module, but the JVM software model dependency resolution is doing this.
    // TODO Ditch the JVM Software Model plugins and re-add this assertion
    // assert selected.getModule() == targetModule;
    this.selected = selected;
}
Also used : ComponentSelectionDescriptorInternal(org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal)

Example 4 with ComponentSelectionDescriptorInternal

use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal in project gradle by gradle.

the class DefaultDependencySubstitutions method substitute.

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

        Action<? super ArtifactSelectionDetails> artifactAction = Actions.doNothing();

        ComponentSelectionDescriptorInternal substitutionReason = (ComponentSelectionDescriptorInternal) reason;

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

        @Override
        public Substitution withClassifier(String classifier) {
            artifactAction = Actions.composite(artifactAction, new SetClassifier(classifier));
            return this;
        }

        @Override
        public Substitution withoutClassifier() {
            artifactAction = Actions.composite(artifactAction, NoClassifier.INSTANCE);
            return this;
        }

        @Override
        public Substitution withoutArtifactSelectors() {
            artifactAction = Actions.composite(artifactAction, NoArtifactSelector.INSTANCE);
            return this;
        }

        @Override
        public Substitution using(ComponentSelector notation) {
            DefaultDependencySubstitution.validateTarget(notation);
            boolean projectInvolved = false;
            if (substituted instanceof ProjectComponentSelector || notation instanceof ProjectComponentSelector) {
                // A project is involved, need to be aware of it
                projectInvolved = true;
            }
            if (substituted instanceof UnversionedModuleComponentSelector) {
                final ModuleIdentifier moduleId = ((UnversionedModuleComponentSelector) substituted).getModuleIdentifier();
                if (notation instanceof ModuleComponentSelector) {
                    if (((ModuleComponentSelector) notation).getModuleIdentifier().equals(moduleId)) {
                        // This substitution is effectively a force
                        substitutionReason = substitutionReason.markAsEquivalentToForce();
                    }
                }
                addSubstitution(new ModuleMatchDependencySubstitutionAction(substitutionReason, moduleId, notation, () -> artifactAction), projectInvolved);
            } else {
                addSubstitution(new ExactMatchDependencySubstitutionAction(substitutionReason, substituted, notation, () -> artifactAction), projectInvolved);
            }
            return this;
        }

        @Override
        @Deprecated
        public void with(ComponentSelector substitute) {
            // Do not nag for 7.1 as this introduces a performance regression with Android plugin
            // Revisit when upgrading Android plugin
            /*DeprecationLogger.deprecateMethod(Substitution.class, "with(ComponentSelector)")
                    .replaceWith("using(ComponentSelector)")
                    .willBeRemovedInGradle8()
                    .withUpgradeGuideSection(7, "dependency_substitutions_with")
                    .nagUser();*/
            using(substitute);
        }
    };
}
Also used : Action(org.gradle.api.Action) ComponentSelector(org.gradle.api.artifacts.component.ComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector) ProjectComponentSelector(org.gradle.api.artifacts.component.ProjectComponentSelector) DefaultProjectComponentSelector(org.gradle.internal.component.local.model.DefaultProjectComponentSelector) ArtifactSelectionDetails(org.gradle.api.artifacts.ArtifactSelectionDetails) DependencySubstitution(org.gradle.api.artifacts.DependencySubstitution) ProjectComponentSelector(org.gradle.api.artifacts.component.ProjectComponentSelector) DefaultProjectComponentSelector(org.gradle.internal.component.local.model.DefaultProjectComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector) ComponentSelectionDescriptorInternal(org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier)

Example 5 with ComponentSelectionDescriptorInternal

use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal in project gradle by gradle.

the class DependencyState method addMainReason.

private void addMainReason(List<ComponentSelectionDescriptorInternal> reasons) {
    ComponentSelectionDescriptorInternal dependencyDescriptor;
    if (reasons.contains(BY_ANCESTOR)) {
        dependencyDescriptor = BY_ANCESTOR;
    } else {
        dependencyDescriptor = dependency.isConstraint() ? CONSTRAINT : REQUESTED;
    }
    String reason = dependency.getReason();
    if (reason != null) {
        dependencyDescriptor = dependencyDescriptor.withDescription(Describables.of(reason));
    }
    maybeAddReason(reasons, dependencyDescriptor);
}
Also used : ComponentSelectionDescriptorInternal(org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal)

Aggregations

ComponentSelectionDescriptorInternal (org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionDescriptorInternal)12 ModuleIdentifier (org.gradle.api.artifacts.ModuleIdentifier)2 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)2 ComponentSelectionDescriptor (org.gradle.api.artifacts.result.ComponentSelectionDescriptor)2 ComponentSelectionReasonInternal (org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.ComponentSelectionReasonInternal)2 DefaultModuleComponentSelector (org.gradle.internal.component.external.model.DefaultModuleComponentSelector)2 Action (org.gradle.api.Action)1 ArtifactSelectionDetails (org.gradle.api.artifacts.ArtifactSelectionDetails)1 DependencySubstitution (org.gradle.api.artifacts.DependencySubstitution)1 ComponentSelector (org.gradle.api.artifacts.component.ComponentSelector)1 ProjectComponentSelector (org.gradle.api.artifacts.component.ProjectComponentSelector)1 ModuleReplacementsData (org.gradle.api.internal.artifacts.dsl.ModuleReplacementsData)1 ComponentResolutionState (org.gradle.api.internal.artifacts.ivyservice.resolveengine.ComponentResolutionState)1 DefaultConflictResolverDetails (org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.conflicts.DefaultConflictResolverDetails)1 VersionConflictResolutionDetails (org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.conflicts.VersionConflictResolutionDetails)1 DefaultSection (org.gradle.api.tasks.diagnostics.internal.graph.nodes.DefaultSection)1 Section (org.gradle.api.tasks.diagnostics.internal.graph.nodes.Section)1 DefaultProjectComponentSelector (org.gradle.internal.component.local.model.DefaultProjectComponentSelector)1 RejectedByAttributesVersion (org.gradle.internal.resolve.RejectedByAttributesVersion)1 RejectedByRuleVersion (org.gradle.internal.resolve.RejectedByRuleVersion)1