Search in sources :

Example 1 with LocallyAvailableResourceCandidates

use of org.gradle.internal.resource.local.LocallyAvailableResourceCandidates in project gradle by gradle.

the class DefaultExternalResourceArtifactResolver method downloadStaticResource.

private LocallyAvailableExternalResource downloadStaticResource(List<ResourcePattern> patternList, final ModuleComponentArtifactMetadata artifact, ResourceAwareResolveResult result) {
    for (ResourcePattern resourcePattern : patternList) {
        ExternalResourceName location = resourcePattern.getLocation(artifact);
        result.attempted(location);
        LOGGER.debug("Loading {}", location);
        LocallyAvailableResourceCandidates localCandidates = locallyAvailableResourceFinder.findCandidates(artifact);
        try {
            LocallyAvailableExternalResource resource = resourceAccessor.getResource(location.getUri(), new CacheAwareExternalResourceAccessor.ResourceFileStore() {

                public LocallyAvailableResource moveIntoCache(File downloadedResource) {
                    return fileStore.move(artifact.getId(), downloadedResource);
                }
            }, localCandidates);
            if (resource != null) {
                return resource;
            }
        } catch (Exception e) {
            throw ResourceExceptions.getFailed(location.getUri(), e);
        }
    }
    return null;
}
Also used : ExternalResourceName(org.gradle.internal.resource.ExternalResourceName) LocallyAvailableResource(org.gradle.internal.resource.local.LocallyAvailableResource) LocallyAvailableResourceCandidates(org.gradle.internal.resource.local.LocallyAvailableResourceCandidates) LocallyAvailableExternalResource(org.gradle.internal.resource.local.LocallyAvailableExternalResource) CacheAwareExternalResourceAccessor(org.gradle.internal.resource.transfer.CacheAwareExternalResourceAccessor) File(java.io.File)

Aggregations

File (java.io.File)1 ExternalResourceName (org.gradle.internal.resource.ExternalResourceName)1 LocallyAvailableExternalResource (org.gradle.internal.resource.local.LocallyAvailableExternalResource)1 LocallyAvailableResource (org.gradle.internal.resource.local.LocallyAvailableResource)1 LocallyAvailableResourceCandidates (org.gradle.internal.resource.local.LocallyAvailableResourceCandidates)1 CacheAwareExternalResourceAccessor (org.gradle.internal.resource.transfer.CacheAwareExternalResourceAccessor)1