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);
}
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;
}
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);
}
}
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;
}
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);
}
Aggregations