Search in sources :

Example 1 with BuildableModuleComponentMetaDataResolveResult

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;
}
Also used : BuildableModuleComponentMetaDataResolveResult(org.gradle.internal.resolve.result.BuildableModuleComponentMetaDataResolveResult)

Example 2 with BuildableModuleComponentMetaDataResolveResult

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;
}
Also used : BuildableModuleComponentMetaDataResolveResult(org.gradle.internal.resolve.result.BuildableModuleComponentMetaDataResolveResult) ModuleComponentArtifactMetadata(org.gradle.internal.component.external.model.ModuleComponentArtifactMetadata) LocallyAvailableExternalResource(org.gradle.internal.resource.local.LocallyAvailableExternalResource) MutableModuleSources(org.gradle.internal.component.model.MutableModuleSources) ExternalResourceResolverDescriptorParseContext(org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolverDescriptorParseContext) MetaDataParser(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.MetaDataParser) File(java.io.File) ExternalResourceMetaData(org.gradle.internal.resource.metadata.ExternalResourceMetaData) Nullable(javax.annotation.Nullable)

Aggregations

BuildableModuleComponentMetaDataResolveResult (org.gradle.internal.resolve.result.BuildableModuleComponentMetaDataResolveResult)2 File (java.io.File)1 Nullable (javax.annotation.Nullable)1 MetaDataParser (org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.MetaDataParser)1 ExternalResourceResolverDescriptorParseContext (org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolverDescriptorParseContext)1 ModuleComponentArtifactMetadata (org.gradle.internal.component.external.model.ModuleComponentArtifactMetadata)1 MutableModuleSources (org.gradle.internal.component.model.MutableModuleSources)1 LocallyAvailableExternalResource (org.gradle.internal.resource.local.LocallyAvailableExternalResource)1 ExternalResourceMetaData (org.gradle.internal.resource.metadata.ExternalResourceMetaData)1