Search in sources :

Example 1 with LocallyAvailableExternalResource

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

the class AbstractModuleDescriptorParser method parseMetaData.

public T parseMetaData(DescriptorParseContext ivySettings, File descriptorFile, boolean validate) throws MetaDataParseException {
    LocallyAvailableResource localResource = new DefaultLocallyAvailableResource(descriptorFile);
    LocallyAvailableExternalResource resource = new DefaultLocallyAvailableExternalResource(descriptorFile.toURI(), localResource);
    return parseDescriptor(ivySettings, resource, validate);
}
Also used : LocallyAvailableResource(org.gradle.internal.resource.local.LocallyAvailableResource) DefaultLocallyAvailableResource(org.gradle.internal.resource.local.DefaultLocallyAvailableResource) DefaultLocallyAvailableExternalResource(org.gradle.internal.resource.local.DefaultLocallyAvailableExternalResource) DefaultLocallyAvailableResource(org.gradle.internal.resource.local.DefaultLocallyAvailableResource) DefaultLocallyAvailableExternalResource(org.gradle.internal.resource.local.DefaultLocallyAvailableExternalResource) LocallyAvailableExternalResource(org.gradle.internal.resource.local.LocallyAvailableExternalResource)

Example 2 with LocallyAvailableExternalResource

use of org.gradle.internal.resource.local.LocallyAvailableExternalResource 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)

Example 3 with LocallyAvailableExternalResource

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

the class ExternalRepositoryResourceAccessor method withResource.

@Override
public void withResource(String relativePath, Action<? super InputStream> action) {
    try {
        String scheme = rootUri.getScheme();
        String host = rootUri.getHost();
        String path = makePath(rootUri.getPath());
        int port = rootUri.getPort();
        String userInfo = rootUri.getUserInfo();
        URI uri = new URI(scheme, userInfo, host, port, path + relativePath, null, null);
        Hasher hasher = Hashing.sha1().newHasher().putString(uri.toASCIIString(), Charsets.UTF_8);
        final String key = hasher.hash().toString();
        LocallyAvailableExternalResource resource = resourceAccessor.getResource(uri, new CacheAwareExternalResourceAccessor.ResourceFileStore() {

            @Override
            public LocallyAvailableResource moveIntoCache(File downloadedResource) {
                return fileStore.move(key, downloadedResource);
            }
        }, null);
        if (resource != null) {
            resource.withContent(action);
        }
    } catch (Exception e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
}
Also used : Hasher(com.google.common.hash.Hasher) LocallyAvailableResource(org.gradle.internal.resource.local.LocallyAvailableResource) LocallyAvailableExternalResource(org.gradle.internal.resource.local.LocallyAvailableExternalResource) URI(java.net.URI) CacheAwareExternalResourceAccessor(org.gradle.internal.resource.transfer.CacheAwareExternalResourceAccessor) File(java.io.File) UncheckedException(org.gradle.internal.UncheckedException)

Example 4 with LocallyAvailableExternalResource

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

the class GradlePomModuleDescriptorParser method parsePom.

private PomReader parsePom(DescriptorParseContext parseContext, ModuleComponentIdentifier parentId, Map<String, String> childProperties) throws IOException, SAXException {
    LocallyAvailableExternalResource localResource = parseContext.getMetaDataArtifact(parentId, ArtifactType.MAVEN_POM);
    PomReader pomReader = new PomReader(localResource, moduleIdentifierFactory, childProperties);
    GradlePomModuleDescriptorBuilder mdBuilder = new GradlePomModuleDescriptorBuilder(pomReader, gradleVersionSelectorScheme, mavenVersionSelectorScheme, moduleIdentifierFactory, moduleExclusions);
    doParsePom(parseContext, mdBuilder, pomReader);
    return pomReader;
}
Also used : LocallyAvailableExternalResource(org.gradle.internal.resource.local.LocallyAvailableExternalResource)

Example 5 with LocallyAvailableExternalResource

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

the class ExternalResourceResolver method parseMetaDataFromArtifact.

@Nullable
protected S parseMetaDataFromArtifact(ModuleComponentIdentifier moduleComponentIdentifier, ExternalResourceArtifactResolver artifactResolver, ResourceAwareResolveResult result) {
    ModuleComponentArtifactMetadata artifact = getMetaDataArtifactFor(moduleComponentIdentifier);
    LocallyAvailableExternalResource metaDataResource = artifactResolver.resolveArtifact(artifact, result);
    if (metaDataResource == null) {
        return null;
    }
    ExternalResourceResolverDescriptorParseContext context = new ExternalResourceResolverDescriptorParseContext(componentResolvers);
    return parseMetaDataFromResource(moduleComponentIdentifier, metaDataResource, context);
}
Also used : DefaultModuleComponentArtifactMetadata(org.gradle.internal.component.external.model.DefaultModuleComponentArtifactMetadata) ModuleComponentArtifactMetadata(org.gradle.internal.component.external.model.ModuleComponentArtifactMetadata) LocallyAvailableExternalResource(org.gradle.internal.resource.local.LocallyAvailableExternalResource) Nullable(org.gradle.api.Nullable)

Aggregations

LocallyAvailableExternalResource (org.gradle.internal.resource.local.LocallyAvailableExternalResource)5 LocallyAvailableResource (org.gradle.internal.resource.local.LocallyAvailableResource)3 File (java.io.File)2 CacheAwareExternalResourceAccessor (org.gradle.internal.resource.transfer.CacheAwareExternalResourceAccessor)2 Hasher (com.google.common.hash.Hasher)1 URI (java.net.URI)1 Nullable (org.gradle.api.Nullable)1 UncheckedException (org.gradle.internal.UncheckedException)1 DefaultModuleComponentArtifactMetadata (org.gradle.internal.component.external.model.DefaultModuleComponentArtifactMetadata)1 ModuleComponentArtifactMetadata (org.gradle.internal.component.external.model.ModuleComponentArtifactMetadata)1 ExternalResourceName (org.gradle.internal.resource.ExternalResourceName)1 DefaultLocallyAvailableExternalResource (org.gradle.internal.resource.local.DefaultLocallyAvailableExternalResource)1 DefaultLocallyAvailableResource (org.gradle.internal.resource.local.DefaultLocallyAvailableResource)1 LocallyAvailableResourceCandidates (org.gradle.internal.resource.local.LocallyAvailableResourceCandidates)1