use of org.gradle.internal.resource.ExternalResourceName in project gradle by gradle.
the class ResourceVersionLister method listRevisionToken.
// lists all the values a revision token listed by a given url lister
private List<String> listRevisionToken(ExternalResourceName versionListPattern, BuildableModuleVersionListingResolveResult result, Map<ResourcePattern, ExternalResourceName> versionListPatterns) {
String pattern = versionListPattern.getPath();
if (!pattern.contains(REVISION_TOKEN)) {
LOGGER.debug("revision token not defined in pattern {}.", pattern);
return Collections.emptyList();
}
String prefix = pattern.substring(0, pattern.indexOf(REVISION_TOKEN));
List<String> listedVersions;
if (revisionMatchesDirectoryName(pattern)) {
ExternalResourceName parent = versionListPattern.getRoot().resolve(prefix);
listedVersions = listAll(parent, result);
} else {
int parentFolderSlashIndex = prefix.lastIndexOf(fileSeparator);
String revisionParentFolder = parentFolderSlashIndex == -1 ? "" : prefix.substring(0, parentFolderSlashIndex + 1);
ExternalResourceName parent = versionListPattern.getRoot().resolve(revisionParentFolder);
LOGGER.debug("using {} to list all in {} ", repository, revisionParentFolder);
result.attempted(parent);
List<String> all = listWithCache(parent);
if (all == null) {
return Collections.emptyList();
}
LOGGER.debug("found {} urls", all.size());
Pattern regexPattern = createRegexPattern(pattern, parentFolderSlashIndex);
listedVersions = filterMatchedValues(all, regexPattern);
LOGGER.debug("{} matched {}", listedVersions.size(), pattern);
}
if (versionListPatterns.size() > 1) {
// Verify that none of the listed "versions" do match another pattern
return filterOutMatchesWithOverlappingPatterns(listedVersions, versionListPattern, versionListPatterns.values());
}
return listedVersions;
}
use of org.gradle.internal.resource.ExternalResourceName in project gradle by gradle.
the class DefaultExternalResourceArtifactResolver method staticResourceExists.
private boolean staticResourceExists(List<ResourcePattern> patternList, 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);
try {
if (repository.resource(location, true).getMetaData() != null) {
return true;
}
} catch (Exception e) {
throw ResourceExceptions.getFailed(location.getUri(), e);
}
}
return false;
}
use of org.gradle.internal.resource.ExternalResourceName in project gradle by gradle.
the class ExternalResourceResolver method publish.
public void publish(ModuleComponentArtifactMetadata artifact, File src) {
ResourcePattern destinationPattern;
if ("ivy".equals(artifact.getName().getType()) && !ivyPatterns.isEmpty()) {
destinationPattern = ivyPatterns.get(0);
} else if (!artifactPatterns.isEmpty()) {
destinationPattern = artifactPatterns.get(0);
} else {
throw new IllegalStateException("impossible to publish " + artifact + " using " + this + ": no artifact pattern defined");
}
ExternalResourceName destination = destinationPattern.getLocation(artifact);
put(src, destination);
LOGGER.info("Published {} to {}", artifact, destination);
}
use of org.gradle.internal.resource.ExternalResourceName in project gradle by gradle.
the class ExternalRepositoryResourceAccessor method isUpToDate.
@Override
public boolean isUpToDate(String resource, @Nullable Long oldValue) {
String[] parts = resource.split(";");
if (!rootUriAsString.equals(parts[0])) {
// not the same provider
return false;
}
ExternalResourceName externalResourceName = new ExternalResourceName(rootUri, parts[1]);
LocallyAvailableExternalResource locallyAvailableExternalResource = resourceResolver.resolveResource(externalResourceName);
return Objects.equal(oldValue, hashFor(locallyAvailableExternalResource));
}
use of org.gradle.internal.resource.ExternalResourceName in project gradle by gradle.
the class ExternalRepositoryResourceAccessor method withResource.
@Override
public void withResource(String relativePath, Action<? super InputStream> action) {
ExternalResourceName location = new ExternalResourceName(rootUri, relativePath);
LocallyAvailableExternalResource resource = resourceResolver.resolveResource(location);
if (resource != null) {
resource.withContent(action);
}
}
Aggregations