use of org.gradle.internal.resource.ExternalResourceName in project gradle by gradle.
the class ExternalResourceResolver method putChecksum.
private void putChecksum(File source, ExternalResourceName destination) {
byte[] checksumFile = createChecksumFile(source, "SHA1", 40);
ExternalResourceName checksumDestination = destination.append(".sha1");
repository.resource(checksumDestination).put(new ByteArrayReadableContent(checksumFile));
}
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) {
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));
if (revisionMatchesDirectoryName(pattern)) {
ExternalResourceName parent = versionListPattern.getRoot().resolve(prefix);
return 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);
if (!visitedDirectories.add(parent)) {
return Collections.emptyList();
}
result.attempted(parent);
List<String> all = repository.resource(parent).list();
if (all == null) {
return Collections.emptyList();
}
LOGGER.debug("found {} urls", all.size());
Pattern regexPattern = createRegexPattern(pattern, parentFolderSlashIndex);
List<String> ret = filterMatchedValues(all, regexPattern);
LOGGER.debug("{} matched {}", ret.size(), pattern);
return ret;
}
}
use of org.gradle.internal.resource.ExternalResourceName in project gradle by gradle.
the class RepositoryTransportWagonAdapter method getRemoteFile.
public boolean getRemoteFile(File destination, String resourceName) throws ResourceException {
ExternalResourceName location = getLocationForResource(resourceName);
ExternalResource resource = transport.getRepository().resource(location);
return resource.writeToIfPresent(destination) != null;
}
use of org.gradle.internal.resource.ExternalResourceName in project gradle by gradle.
the class AbstractMavenPublisher method publish.
protected void publish(MavenNormalizedPublication publication, ExternalResourceRepository repository, URI rootUri, boolean localRepo) {
String groupId = publication.getGroupId();
String artifactId = publication.getArtifactId();
String version = publication.getVersion();
ModuleArtifactPublisher artifactPublisher = new ModuleArtifactPublisher(repository, localRepo, rootUri, groupId, artifactId, version);
if (isSnapshot(version)) {
ExternalResourceName snapshotMetadataPath = artifactPublisher.getSnapshotMetadataLocation();
Metadata snapshotMetadata = createSnapshotMetadata(publication, groupId, artifactId, version, repository, snapshotMetadataPath);
artifactPublisher.publish(snapshotMetadataPath, writeMetadataToTmpFile(snapshotMetadata, "snapshot-maven-metadata.xml"));
if (!localRepo) {
// Use the timestamped version for all published artifacts:
// The timestamped version is hidden deep in `Metadata.versioning.snapshotVersions`
artifactPublisher.artifactVersion = snapshotMetadata.getVersioning().getSnapshotVersions().get(0).getVersion();
}
}
if (publication.getMainArtifact() != null) {
artifactPublisher.publish(null, publication.getMainArtifact().getExtension(), publication.getMainArtifact().getFile());
}
artifactPublisher.publish(null, "pom", publication.getPomArtifact().getFile());
for (MavenArtifact artifact : publication.getAdditionalArtifacts()) {
artifactPublisher.publish(artifact.getClassifier(), artifact.getExtension(), artifact.getFile());
}
ExternalResourceName externalResource = artifactPublisher.getMetadataLocation();
Metadata metadata = createMetadata(groupId, artifactId, version, repository, externalResource);
artifactPublisher.publish(externalResource, writeMetadataToTmpFile(metadata, "module-maven-metadata.xml"));
}
use of org.gradle.internal.resource.ExternalResourceName in project gradle by gradle.
the class IvyResourcePattern method toModuleVersionPath.
@Override
public ExternalResourceName toModuleVersionPath(ModuleComponentIdentifier componentIdentifier) {
ImmutableMap<String, String> attributes = ImmutableMap.of("organisation", componentIdentifier.getGroup(), "module", componentIdentifier.getModule(), "artifact", componentIdentifier.getModule(), "revision", componentIdentifier.getVersion());
ExternalResourceName resolve = getBase().getRoot().resolve(substituteTokens(getPathWithoutArtifactPart(), attributes));
return resolve;
}
Aggregations