use of org.gradle.api.artifacts.ComponentSelection 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.ComponentSelection in project gradle by gradle.
the class DefaultComponentSelectionRules method createSpecRuleActionFromId.
private SpecRuleAction<? super ComponentSelection> createSpecRuleActionFromId(Object id, RuleAction<? super ComponentSelection> ruleAction) {
final ModuleIdentifier moduleIdentifier;
try {
moduleIdentifier = moduleIdentifierNotationParser.parseNotation(id);
} catch (UnsupportedNotationException e) {
throw new InvalidUserCodeException(String.format(INVALID_SPEC_ERROR, id == null ? "null" : id.toString()), e);
}
Spec<ComponentSelection> spec = new ComponentSelectionMatchingSpec(moduleIdentifier);
return new SpecRuleAction<ComponentSelection>(ruleAction, spec);
}
Aggregations