Search in sources :

Example 1 with ModuleComponentArtifactMetadata

use of org.gradle.internal.component.external.model.ModuleComponentArtifactMetadata in project gradle by gradle.

the class ClientModuleResolver method setClientModuleArtifact.

private void setClientModuleArtifact(MutableModuleComponentResolveMetadata clientModuleMetaData) {
    ModuleComponentArtifactMetadata artifact = clientModuleMetaData.artifact("jar", "jar", null);
    clientModuleMetaData.setArtifacts(Sets.newHashSet(artifact));
}
Also used : ModuleComponentArtifactMetadata(org.gradle.internal.component.external.model.ModuleComponentArtifactMetadata)

Example 2 with ModuleComponentArtifactMetadata

use of org.gradle.internal.component.external.model.ModuleComponentArtifactMetadata in project gradle by gradle.

the class ExternalResourceResolver method resolveArtifact.

protected void resolveArtifact(ComponentArtifactMetadata componentArtifact, ModuleSource moduleSource, BuildableArtifactResolveResult result) {
    ModuleComponentArtifactMetadata artifact = (ModuleComponentArtifactMetadata) componentArtifact;
    File localFile;
    try {
        localFile = download(artifact, moduleSource, result);
    } catch (Throwable e) {
        result.failed(new ArtifactResolveException(artifact.getId(), e));
        return;
    }
    if (localFile != null) {
        result.resolved(localFile);
    } else {
        result.notFound(artifact.getId());
    }
}
Also used : ArtifactResolveException(org.gradle.internal.resolve.ArtifactResolveException) DefaultModuleComponentArtifactMetadata(org.gradle.internal.component.external.model.DefaultModuleComponentArtifactMetadata) ModuleComponentArtifactMetadata(org.gradle.internal.component.external.model.ModuleComponentArtifactMetadata) File(java.io.File)

Example 3 with ModuleComponentArtifactMetadata

use of org.gradle.internal.component.external.model.ModuleComponentArtifactMetadata in project gradle by gradle.

the class ComponentArtifactMetadataSerializer method write.

public void write(Encoder encoder, ComponentArtifactMetadata value) throws Exception {
    if (value instanceof ModuleComponentArtifactMetadata) {
        ModuleComponentArtifactMetadata moduleComponentArtifactMetadata = (ModuleComponentArtifactMetadata) value;
        componentIdentifierSerializer.write(encoder, moduleComponentArtifactMetadata.getComponentId());
        IvyArtifactName ivyArtifactName = moduleComponentArtifactMetadata.getName();
        encoder.writeString(ivyArtifactName.getName());
        encoder.writeString(ivyArtifactName.getType());
        encoder.writeNullableString(ivyArtifactName.getExtension());
        encoder.writeNullableString(ivyArtifactName.getClassifier());
    } else {
        throw new IllegalArgumentException("Unknown artifact metadata type.");
    }
}
Also used : IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) ModuleComponentArtifactMetadata(org.gradle.internal.component.external.model.ModuleComponentArtifactMetadata) DefaultModuleComponentArtifactMetadata(org.gradle.internal.component.external.model.DefaultModuleComponentArtifactMetadata)

Example 4 with ModuleComponentArtifactMetadata

use of org.gradle.internal.component.external.model.ModuleComponentArtifactMetadata in project gradle by gradle.

the class LocallyAvailableResourceFinderFactory method create.

public LocallyAvailableResourceFinder<ModuleComponentArtifactMetadata> create() {
    List<LocallyAvailableResourceFinder<ModuleComponentArtifactMetadata>> finders = new LinkedList<LocallyAvailableResourceFinder<ModuleComponentArtifactMetadata>>();
    // Order is important here, because they will be searched in that order
    // The current filestore
    finders.add(new LocallyAvailableResourceFinderSearchableFileStoreAdapter<ModuleComponentArtifactMetadata>(new FileStoreSearcher<ModuleComponentArtifactMetadata>() {

        @Override
        public Set<? extends LocallyAvailableResource> search(ModuleComponentArtifactMetadata key) {
            return fileStore.search(key.getId());
        }
    }));
    // 1.8
    addForPattern(finders, "artifacts-26/filestore/[organisation]/[module](/[branch])/[revision]/[type]/*/[artifact]-[revision](-[classifier])(.[ext])");
    // 1.5
    addForPattern(finders, "artifacts-24/filestore/[organisation]/[module](/[branch])/[revision]/[type]/*/[artifact]-[revision](-[classifier])(.[ext])");
    // 1.4
    addForPattern(finders, "artifacts-23/filestore/[organisation]/[module](/[branch])/[revision]/[type]/*/[artifact]-[revision](-[classifier])(.[ext])");
    // 1.3
    addForPattern(finders, "artifacts-15/filestore/[organisation]/[module](/[branch])/[revision]/[type]/*/[artifact]-[revision](-[classifier])(.[ext])");
    // 1.1, 1.2
    addForPattern(finders, "artifacts-14/filestore/[organisation]/[module](/[branch])/[revision]/[type]/*/[artifact]-[revision](-[classifier])(.[ext])");
    // rc-1, 1.0
    addForPattern(finders, "artifacts-13/filestore/[organisation]/[module](/[branch])/[revision]/[type]/*/[artifact]-[revision](-[classifier])(.[ext])");
    // Milestone 8 and 9
    addForPattern(finders, "artifacts-8/filestore/[organisation]/[module](/[branch])/[revision]/[type]/*/[artifact]-[revision](-[classifier])(.[ext])");
    // Milestone 7
    addForPattern(finders, "artifacts-7/artifacts/*/[organisation]/[module](/[branch])/[revision]/[type]/[artifact]-[revision](-[classifier])(.[ext])");
    // Milestone 6
    addForPattern(finders, "artifacts-4/[organisation]/[module](/[branch])/*/[type]s/[artifact]-[revision](-[classifier])(.[ext])");
    addForPattern(finders, "artifacts-4/[organisation]/[module](/[branch])/*/pom.originals/[artifact]-[revision](-[classifier])(.[ext])");
    // Milestone 3
    addForPattern(finders, "../cache/[organisation]/[module](/[branch])/[type]s/[artifact]-[revision](-[classifier])(.[ext])");
    // Maven local
    try {
        File localMavenRepository = localMavenRepositoryLocator.getLocalMavenRepository();
        if (localMavenRepository.exists()) {
            addForPattern(finders, localMavenRepository, new M2ResourcePattern("[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])"));
        }
    } catch (CannotLocateLocalMavenRepositoryException ex) {
        finders.add(new NoMavenLocalRepositoryResourceFinder(ex));
    }
    return new CompositeLocallyAvailableResourceFinder<ModuleComponentArtifactMetadata>(finders);
}
Also used : M2ResourcePattern(org.gradle.api.internal.artifacts.repositories.resolver.M2ResourcePattern) LocallyAvailableResourceFinder(org.gradle.internal.resource.local.LocallyAvailableResourceFinder) CompositeLocallyAvailableResourceFinder(org.gradle.internal.resource.local.CompositeLocallyAvailableResourceFinder) ModuleComponentArtifactMetadata(org.gradle.internal.component.external.model.ModuleComponentArtifactMetadata) FileStoreSearcher(org.gradle.internal.resource.local.FileStoreSearcher) File(java.io.File) CannotLocateLocalMavenRepositoryException(org.gradle.api.internal.artifacts.mvnsettings.CannotLocateLocalMavenRepositoryException) CompositeLocallyAvailableResourceFinder(org.gradle.internal.resource.local.CompositeLocallyAvailableResourceFinder) LinkedList(java.util.LinkedList)

Example 5 with ModuleComponentArtifactMetadata

use of org.gradle.internal.component.external.model.ModuleComponentArtifactMetadata in project gradle by gradle.

the class ExternalResourceResolver method parseMetaDataFromArtifact.

@Nullable
protected S parseMetaDataFromArtifact(ModuleComponentIdentifier moduleComponentIdentifier, ExternalResourceArtifactResolver artifactResolver, ResourceAwareResolveResult result) {
    ModuleComponentArtifactMetadata artifact = getMetaDataArtifactFor(moduleComponentIdentifier);
    LocallyAvailableExternalResource metaDataResource = artifactResolver.resolveArtifact(artifact, result);
    if (metaDataResource == null) {
        return null;
    }
    ExternalResourceResolverDescriptorParseContext context = new ExternalResourceResolverDescriptorParseContext(componentResolvers);
    return parseMetaDataFromResource(moduleComponentIdentifier, metaDataResource, context);
}
Also used : DefaultModuleComponentArtifactMetadata(org.gradle.internal.component.external.model.DefaultModuleComponentArtifactMetadata) ModuleComponentArtifactMetadata(org.gradle.internal.component.external.model.ModuleComponentArtifactMetadata) LocallyAvailableExternalResource(org.gradle.internal.resource.local.LocallyAvailableExternalResource) Nullable(org.gradle.api.Nullable)

Aggregations

ModuleComponentArtifactMetadata (org.gradle.internal.component.external.model.ModuleComponentArtifactMetadata)6 DefaultModuleComponentArtifactMetadata (org.gradle.internal.component.external.model.DefaultModuleComponentArtifactMetadata)3 File (java.io.File)2 LinkedList (java.util.LinkedList)1 Nullable (org.gradle.api.Nullable)1 CannotLocateLocalMavenRepositoryException (org.gradle.api.internal.artifacts.mvnsettings.CannotLocateLocalMavenRepositoryException)1 M2ResourcePattern (org.gradle.api.internal.artifacts.repositories.resolver.M2ResourcePattern)1 DefaultIvyArtifactName (org.gradle.internal.component.model.DefaultIvyArtifactName)1 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)1 ArtifactResolveException (org.gradle.internal.resolve.ArtifactResolveException)1 DefaultResourceAwareResolveResult (org.gradle.internal.resolve.result.DefaultResourceAwareResolveResult)1 CompositeLocallyAvailableResourceFinder (org.gradle.internal.resource.local.CompositeLocallyAvailableResourceFinder)1 FileStoreSearcher (org.gradle.internal.resource.local.FileStoreSearcher)1 LocallyAvailableExternalResource (org.gradle.internal.resource.local.LocallyAvailableExternalResource)1 LocallyAvailableResourceFinder (org.gradle.internal.resource.local.LocallyAvailableResourceFinder)1