use of org.gradle.internal.resource.local.LocallyAvailableResource in project gradle by gradle.
the class DirectoryBuildCacheService method loadInsideLock.
private void loadInsideLock(BuildCacheKey key, Action<? super File> reader) {
LocallyAvailableResource resource = fileStore.get(key.getHashCode());
if (resource == null) {
return;
}
File file = resource.getFile();
touch(file);
try {
reader.execute(file);
} catch (Exception e) {
// Try to move the file out of the way in case its permanently corrupt
// Don't delete, so that it can be potentially used for debugging
File failedFile = new File(file.getAbsolutePath() + failedFileSuffix);
GFileUtils.deleteQuietly(failedFile);
// noinspection ResultOfMethodCallIgnored
file.renameTo(failedFile);
throw UncheckedException.throwAsUncheckedException(e);
}
}
use of org.gradle.internal.resource.local.LocallyAvailableResource in project gradle by gradle.
the class ExternalResourceResolverDescriptorParseContext method getMetaDataArtifact.
public LocallyAvailableExternalResource getMetaDataArtifact(ModuleComponentIdentifier moduleComponentIdentifier, ArtifactType artifactType) {
File resolvedArtifactFile = resolveMetaDataArtifactFile(moduleComponentIdentifier, mainResolvers.getComponentResolver(), mainResolvers.getArtifactResolver(), artifactType);
LocallyAvailableResource localResource = new DefaultLocallyAvailableResource(resolvedArtifactFile);
return new DefaultLocallyAvailableExternalResource(resolvedArtifactFile.toURI(), localResource);
}
use of org.gradle.internal.resource.local.LocallyAvailableResource in project gradle by gradle.
the class DefaultExternalResourceArtifactResolver method downloadByCoords.
private LocallyAvailableExternalResource downloadByCoords(List<ResourcePattern> patternList, final ModuleComponentArtifactMetadata artifact, ResourceAwareResolveResult result) {
for (ResourcePattern resourcePattern : patternList) {
if (isIncomplete(resourcePattern, artifact)) {
continue;
}
ExternalResourceName location = resourcePattern.getLocation(artifact);
result.attempted(location);
LOGGER.debug("Loading {}", location);
LocallyAvailableResourceCandidates localCandidates = locallyAvailableResourceFinder.findCandidates(artifact);
try {
LocallyAvailableExternalResource resource = resourceAccessor.getResource(location, null, 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 DefaultExternalResourceArtifactResolver method downloadByUrl.
private LocallyAvailableExternalResource downloadByUrl(List<ResourcePattern> patternList, final UrlBackedArtifactMetadata artifact, ResourceAwareResolveResult result) {
for (ResourcePattern resourcePattern : patternList) {
if (isIncomplete(resourcePattern, artifact)) {
continue;
}
ExternalResourceName moduleDir = resourcePattern.toModuleVersionPath(artifact.getComponentId());
ExternalResourceName location = moduleDir.resolve(artifact.getRelativeUrl());
result.attempted(location);
LOGGER.debug("Loading {}", location);
LocallyAvailableResourceCandidates localCandidates = locallyAvailableResourceFinder.findCandidates(artifact);
try {
LocallyAvailableExternalResource resource = resourceAccessor.getResource(location, artifact.getId().getFileName(), 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 GradleBuildOutcomeSetTransformer method addFileBuildOutcome.
private void addFileBuildOutcome(GradleFileBuildOutcome outcome, ProjectOutcomes rootProject, Set<BuildOutcome> translatedOutcomes) {
if (zipArchiveTypes.contains(outcome.getTypeIdentifier())) {
File originalFile = outcome.getFile();
String relativePath = RelativePathUtil.relativePath(rootProject.getProjectDirectory(), originalFile);
LocallyAvailableResource resource = null;
if (originalFile.exists()) {
String filestoreDestination = fileStorePrefix + "/" + outcome.getTaskPath() + "/" + originalFile.getName();
resource = fileStore.move(filestoreDestination, originalFile);
}
BuildOutcome buildOutcome = new GeneratedArchiveBuildOutcome(outcome.getTaskPath(), outcome.getDescription(), resource, relativePath);
translatedOutcomes.add(buildOutcome);
} else {
String outcomeName = outcome.getTaskPath();
if (isEmpty(outcomeName)) {
outcomeName = RelativePathUtil.relativePath(rootProject.getProjectDirectory(), outcome.getFile());
}
translatedOutcomes.add(new UnknownBuildOutcome(outcomeName, outcome.getDescription()));
}
}
Aggregations