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