use of org.gradle.internal.resource.ExternalResourceName 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.ExternalResourceName in project gradle by gradle.
the class MavenVersionLister method newVisitor.
public VersionPatternVisitor newVisitor(final ModuleIdentifier module, final Collection<String> dest, final ResourceAwareResolveResult result) {
return new VersionPatternVisitor() {
final Set<ExternalResourceName> searched = new HashSet<ExternalResourceName>();
public void visit(ResourcePattern pattern, IvyArtifactName artifact) throws ResourceException {
ExternalResourceName metadataLocation = pattern.toModulePath(module).resolve("maven-metadata.xml");
if (!searched.add(metadataLocation)) {
return;
}
result.attempted(metadataLocation);
MavenMetadata mavenMetaData = mavenMetadataLoader.load(metadataLocation.getUri());
for (String version : mavenMetaData.versions) {
dest.add(version);
}
}
};
}
use of org.gradle.internal.resource.ExternalResourceName in project gradle by gradle.
the class ResourceVersionLister method visit.
private void visit(ResourcePattern pattern, IvyArtifactName artifact, ModuleIdentifier module, List<String> collector, BuildableModuleVersionListingResolveResult result) {
ExternalResourceName versionListPattern = pattern.toVersionListPattern(module, artifact);
LOGGER.debug("Listing all in {}", versionListPattern);
try {
List<String> versionStrings = listRevisionToken(versionListPattern, result);
for (String versionString : versionStrings) {
collector.add(versionString);
}
} catch (Exception e) {
throw ResourceExceptions.failure(versionListPattern.getUri(), String.format("Could not list versions using %s.", pattern), e);
}
}
use of org.gradle.internal.resource.ExternalResourceName in project gradle by gradle.
the class ResourceVersionLister method filterOutMatchesWithOverlappingPatterns.
private List<String> filterOutMatchesWithOverlappingPatterns(List<String> listedVersions, ExternalResourceName currentVersionListPattern, Collection<ExternalResourceName> versionListPatterns) {
List<String> remaining = Lists.newArrayList(listedVersions);
for (ExternalResourceName otherVersionListPattern : versionListPatterns) {
if (otherVersionListPattern != currentVersionListPattern) {
String patternPath = otherVersionListPattern.getPath();
Pattern regexPattern = toControlRegexPattern(patternPath);
List<String> matching = listedVersions.stream().filter(version -> regexPattern.matcher(currentVersionListPattern.getPath().replace(REVISION_TOKEN, version)).matches()).collect(Collectors.toList());
if (!matching.isEmpty()) {
LOGGER.debug("Filtered out {} from results for overlapping match with {}", matching, otherVersionListPattern);
remaining.removeAll(matching);
}
}
}
return remaining;
}
use of org.gradle.internal.resource.ExternalResourceName in project gradle by gradle.
the class ResourceVersionLister method visit.
private void visit(ResourcePattern pattern, Map<ResourcePattern, ExternalResourceName> versionListPatterns, List<String> collector, BuildableModuleVersionListingResolveResult result) {
ExternalResourceName versionListPattern = versionListPatterns.get(pattern);
LOGGER.debug("Listing all in {}", versionListPattern);
try {
collector.addAll(listRevisionToken(versionListPattern, result, versionListPatterns));
} catch (Exception e) {
throw ResourceExceptions.failure(versionListPattern.getUri(), String.format("Could not list versions using %s.", pattern), e);
}
}
Aggregations