use of org.gradle.api.artifacts.component.ModuleComponentIdentifier in project gradle by gradle.
the class DefaultVersionedComponentChooser method selectNewestMatchingComponent.
public void selectNewestMatchingComponent(Collection<? extends ModuleComponentResolveState> versions, ComponentSelectionContext result, VersionSelector requestedVersionMatcher, VersionSelector rejectedVersionSelector) {
Collection<SpecRuleAction<? super ComponentSelection>> rules = componentSelectionRules.getRules();
// Loop over all listed versions, sorted by LATEST first
for (ModuleComponentResolveState candidate : sortLatestFirst(versions)) {
MetadataProvider metadataProvider = createMetadataProvider(candidate);
boolean versionMatches = versionMatches(requestedVersionMatcher, candidate, metadataProvider);
if (metadataIsNotUsable(result, metadataProvider)) {
return;
}
String version = candidate.getVersion().getSource();
if (!versionMatches) {
result.notMatched(version);
continue;
}
if (rejectedVersionSelector != null && rejectedVersionSelector.accept(version)) {
// Mark this version as rejected and continue
result.rejected(version);
continue;
} else {
ModuleComponentIdentifier candidateIdentifier = candidate.getId();
if (!isRejectedByRules(candidateIdentifier, rules, metadataProvider)) {
result.matches(candidateIdentifier);
return;
}
}
// Mark this version as rejected
result.rejected(version);
if (requestedVersionMatcher.matchesUniqueVersion()) {
// Only consider one candidate, because matchesUniqueVersion means that there's no ambiguity on the version number
break;
}
}
// if we reach this point, no match was found, either because there are no versions matching the selector
// or all of them were rejected
result.noMatchFound();
}
use of org.gradle.api.artifacts.component.ModuleComponentIdentifier in project gradle by gradle.
the class RepositoryChainComponentMetaDataResolver method isFetchingMetadataCheap.
@Override
public boolean isFetchingMetadataCheap(ComponentIdentifier identifier) {
if (identifier instanceof ModuleComponentIdentifier) {
for (ModuleComponentRepository repository : repositories) {
ModuleComponentRepositoryAccess localAccess = repository.getLocalAccess();
MetadataFetchingCost fetchingCost = localAccess.estimateMetadataFetchingCost((ModuleComponentIdentifier) identifier);
if (fetchingCost.isFast()) {
return true;
} else if (fetchingCost.isExpensive()) {
return false;
}
}
}
return true;
}
use of org.gradle.api.artifacts.component.ModuleComponentIdentifier 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.ModuleComponentIdentifier in project gradle by gradle.
the class GradlePomModuleDescriptorParser method doParseDescriptor.
protected MutableMavenModuleResolveMetadata doParseDescriptor(DescriptorParseContext parserSettings, LocallyAvailableExternalResource resource, boolean validate) throws IOException, ParseException, SAXException {
PomReader pomReader = new PomReader(resource, moduleIdentifierFactory);
GradlePomModuleDescriptorBuilder mdBuilder = new GradlePomModuleDescriptorBuilder(pomReader, gradleVersionSelectorScheme, mavenVersionSelectorScheme);
doParsePom(parserSettings, mdBuilder, pomReader);
List<MavenDependencyDescriptor> dependencies = mdBuilder.getDependencies();
ModuleComponentIdentifier cid = mdBuilder.getComponentIdentifier();
MutableMavenModuleResolveMetadata metadata = metadataFactory.create(cid, dependencies);
metadata.setStatus(mdBuilder.getStatus());
if (pomReader.getRelocation() != null) {
metadata.setPackaging("pom");
metadata.setRelocated(true);
} else {
metadata.setPackaging(pomReader.getPackaging());
metadata.setRelocated(false);
}
return metadata;
}
use of org.gradle.api.artifacts.component.ModuleComponentIdentifier in project gradle by gradle.
the class DefaultArtifactPublisher method toPublishMetaData.
private DefaultIvyModulePublishMetadata toPublishMetaData(Module module, Set<? extends ConfigurationInternal> configurations, boolean validateArtifacts) {
ModuleComponentIdentifier id = DefaultModuleComponentIdentifier.newId(module.getGroup(), module.getName(), module.getVersion());
DefaultIvyModulePublishMetadata publishMetaData = new DefaultIvyModulePublishMetadata(id, module.getStatus());
addConfigurations(publishMetaData, configurations, validateArtifacts);
return publishMetaData;
}
Aggregations