use of org.gradle.internal.resource.local.LocallyAvailableResource 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);
}
use of org.gradle.internal.resource.local.LocallyAvailableResource in project gradle by gradle.
the class DefaultModuleMetaDataCache method cacheMetaData.
public CachedMetaData cacheMetaData(ModuleComponentRepository repository, ModuleComponentResolveMetadata metadata) {
LOGGER.debug("Recording module descriptor in cache: {} [changing = {}]", metadata.getComponentId(), metadata.isChanging());
ModuleComponentAtRepositoryKey key = createKey(repository, metadata.getComponentId());
LocallyAvailableResource resource = moduleMetadataStore.putModuleDescriptor(key, metadata);
ModuleMetadataCacheEntry entry = createEntry(metadata, resource.getSha1());
getCache().put(key, entry);
return new DefaultCachedMetaData(entry, null, timeProvider);
}
use of org.gradle.internal.resource.local.LocallyAvailableResource in project gradle by gradle.
the class ModuleMetadataStore method getModuleDescriptor.
public MutableModuleComponentResolveMetadata getModuleDescriptor(ModuleComponentAtRepositoryKey component) {
String filePath = getFilePath(component);
final LocallyAvailableResource resource = metaDataStore.get(filePath);
if (resource != null) {
try {
KryoBackedDecoder decoder = new KryoBackedDecoder(new FileInputStream(resource.getFile()));
try {
return moduleMetadataSerializer.read(decoder, moduleIdentifierFactory, moduleExclusions);
} finally {
decoder.close();
}
} catch (Exception e) {
throw new RuntimeException("Could not load module metadata from " + resource.getDisplayName(), e);
}
}
return null;
}
use of org.gradle.internal.resource.local.LocallyAvailableResource 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;
}
use of org.gradle.internal.resource.local.LocallyAvailableResource 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);
}
}
Aggregations