Search in sources :

Example 16 with ExternalResourceName

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));
}
Also used : ExternalResourceName(org.gradle.internal.resource.ExternalResourceName) ByteArrayReadableContent(org.gradle.internal.resource.local.ByteArrayReadableContent)

Example 17 with ExternalResourceName

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;
    }
}
Also used : Pattern(java.util.regex.Pattern) ExternalResourceName(org.gradle.internal.resource.ExternalResourceName)

Example 18 with ExternalResourceName

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;
}
Also used : ExternalResourceName(org.gradle.internal.resource.ExternalResourceName) ExternalResource(org.gradle.internal.resource.ExternalResource)

Example 19 with ExternalResourceName

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"));
}
Also used : ExternalResourceName(org.gradle.internal.resource.ExternalResourceName) Metadata(org.apache.maven.artifact.repository.metadata.Metadata) MavenArtifact(org.gradle.api.publish.maven.MavenArtifact)

Example 20 with ExternalResourceName

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;
}
Also used : ExternalResourceName(org.gradle.internal.resource.ExternalResourceName)

Aggregations

ExternalResourceName (org.gradle.internal.resource.ExternalResourceName)25 LocallyAvailableExternalResource (org.gradle.internal.resource.local.LocallyAvailableExternalResource)6 Pattern (java.util.regex.Pattern)4 URI (java.net.URI)3 Nullable (javax.annotation.Nullable)3 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)3 LocallyAvailableResourceCandidates (org.gradle.internal.resource.local.LocallyAvailableResourceCandidates)3 IOException (java.io.IOException)2 URISyntaxException (java.net.URISyntaxException)2 Matcher (java.util.regex.Matcher)2 ExternalResource (org.gradle.internal.resource.ExternalResource)2 ByteArrayReadableContent (org.gradle.internal.resource.local.ByteArrayReadableContent)2 Lists (com.google.common.collect.Lists)1 File (java.io.File)1 ArrayDeque (java.util.ArrayDeque)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1