use of org.gradle.internal.resolve.result.BuildableModuleComponentMetaDataResolveResult in project gradle by gradle.
the class RepositoryChainComponentMetaDataResolver method findBestMatch.
private RepositoryChainModuleResolution findBestMatch(LinkedList<ComponentMetaDataResolveState> queue, Collection<Throwable> failures, Collection<ComponentMetaDataResolveState> missing) {
RepositoryChainModuleResolution best = null;
while (!queue.isEmpty()) {
ComponentMetaDataResolveState request = queue.removeFirst();
BuildableModuleComponentMetaDataResolveResult metaDataResolveResult;
metaDataResolveResult = request.resolve();
switch(metaDataResolveResult.getState()) {
case Failed:
failures.add(metaDataResolveResult.getFailure());
if (isCriticalFailure(metaDataResolveResult.getFailure())) {
queue.clear();
}
break;
case Missing:
// Queue this up for checking again later
if (request.canMakeFurtherAttempts()) {
missing.add(request);
}
break;
case Resolved:
RepositoryChainModuleResolution moduleResolution = new RepositoryChainModuleResolution(request.repository, metaDataResolveResult.getMetaData());
if (!metaDataResolveResult.getMetaData().isMissing()) {
return moduleResolution;
}
best = best != null ? best : moduleResolution;
break;
default:
throw new IllegalStateException("Unexpected state for resolution: " + metaDataResolveResult.getState());
}
}
return best;
}
use of org.gradle.internal.resolve.result.BuildableModuleComponentMetaDataResolveResult in project gradle by gradle.
the class AbstractRepositoryMetadataSource method parseMetaDataFromArtifact.
@Nullable
private S parseMetaDataFromArtifact(String repositoryName, ComponentResolvers componentResolvers, ModuleComponentIdentifier moduleComponentIdentifier, ExternalResourceArtifactResolver artifactResolver, ResourceAwareResolveResult result) {
ModuleComponentArtifactMetadata artifact = getMetaDataArtifactFor(moduleComponentIdentifier);
LocallyAvailableExternalResource metadataArtifact = artifactResolver.resolveArtifact(artifact, result);
if (metadataArtifact != null) {
ExternalResourceResolverDescriptorParseContext context = new ExternalResourceResolverDescriptorParseContext(componentResolvers, fileResourceRepository, checksumService);
MetaDataParser.ParseResult<S> parseResult = parseMetaDataFromResource(moduleComponentIdentifier, metadataArtifact, artifactResolver, context, repositoryName);
if (parseResult != null) {
if (parseResult.hasGradleMetadataRedirectionMarker()) {
if (result instanceof BuildableModuleComponentMetaDataResolveResult) {
((BuildableModuleComponentMetaDataResolveResult) result).redirectToGradleMetadata();
} else {
throw new IllegalStateException("Unexpected Gradle metadata redirection answer");
}
}
S metadata = parseResult.getResult();
File metadataArtifactFile = metadataArtifact.getFile();
ExternalResourceMetaData metaData = metadataArtifact.getMetaData();
MutableModuleSources sources = metadata.getSources();
sources.add(new DefaultMetadataFileSource(artifact.getId(), metadataArtifactFile, findSha1(metaData, metadataArtifactFile)));
context.appendSources(sources);
return metadata;
}
}
return null;
}
Aggregations