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));
}
}
};
}
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);
}
}
}
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);
}
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;
}
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();
}
Aggregations