Search in sources :

Example 1 with ComponentArtifactIdentifier

use of org.gradle.api.artifacts.component.ComponentArtifactIdentifier in project gradle by gradle.

the class LocalFileDependencyBackedArtifactSet method snapshot.

@Override
public ResolvedArtifactSet snapshot() {
    ComponentIdentifier componentIdentifier = dependencyMetadata.getComponentId();
    if (componentIdentifier != null && !componentFilter.isSatisfiedBy(componentIdentifier)) {
        return ResolvedArtifactSet.EMPTY;
    }
    Set<File> files;
    try {
        files = dependencyMetadata.getFiles().getFiles();
    } catch (Throwable throwable) {
        return new FailingResolvedArtifactSetSnapshot(throwable);
    }
    List<ResolvedVariant> variants = Lists.newArrayListWithCapacity(files.size());
    for (File file : files) {
        ComponentArtifactIdentifier artifactIdentifier;
        if (componentIdentifier == null) {
            artifactIdentifier = new OpaqueComponentArtifactIdentifier(file);
            if (!componentFilter.isSatisfiedBy(artifactIdentifier.getComponentIdentifier())) {
                continue;
            }
        } else {
            artifactIdentifier = new ComponentFileArtifactIdentifier(componentIdentifier, file.getName());
        }
        AttributeContainerInternal variantAttributes = DefaultArtifactAttributes.forFile(file, attributesFactory);
        ResolvedVariant variant = new SingletonFileResolvedVariant(file, artifactIdentifier, variantAttributes);
        variants.add(selector.select(Collections.singleton(variant)));
    }
    return new ResolvedVariantBackedArtifactSetSnapshot(variants, dependencyMetadata);
}
Also used : OpaqueComponentArtifactIdentifier(org.gradle.internal.component.local.model.OpaqueComponentArtifactIdentifier) ComponentArtifactIdentifier(org.gradle.api.artifacts.component.ComponentArtifactIdentifier) ComponentIdentifier(org.gradle.api.artifacts.component.ComponentIdentifier) AttributeContainerInternal(org.gradle.api.internal.attributes.AttributeContainerInternal) ComponentFileArtifactIdentifier(org.gradle.internal.component.local.model.ComponentFileArtifactIdentifier) OpaqueComponentArtifactIdentifier(org.gradle.internal.component.local.model.OpaqueComponentArtifactIdentifier) File(java.io.File)

Example 2 with ComponentArtifactIdentifier

use of org.gradle.api.artifacts.component.ComponentArtifactIdentifier in project gradle by gradle.

the class DependencyResolvingClasspath method getFiles.

@Override
public Set<File> getFiles() {
    ensureResolved(true);
    final Set<File> result = new LinkedHashSet<File>();
    resolveResult.artifactsResults.getArtifacts().visit(new ArtifactVisitor() {

        @Override
        public void visitArtifact(AttributeContainer variant, ResolvedArtifact artifact) {
            result.add(artifact.getFile());
        }

        @Override
        public void visitFailure(Throwable failure) {
            throw UncheckedException.throwAsUncheckedException(failure);
        }

        @Override
        public boolean includeFiles() {
            return true;
        }

        @Override
        public void visitFile(ComponentArtifactIdentifier artifactIdentifier, AttributeContainer variant, File file) {
            result.add(file);
        }
    });
    return result;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ComponentArtifactIdentifier(org.gradle.api.artifacts.component.ComponentArtifactIdentifier) ResolvedArtifact(org.gradle.api.artifacts.ResolvedArtifact) AttributeContainer(org.gradle.api.attributes.AttributeContainer) File(java.io.File) ArtifactVisitor(org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ArtifactVisitor)

Aggregations

File (java.io.File)2 ComponentArtifactIdentifier (org.gradle.api.artifacts.component.ComponentArtifactIdentifier)2 LinkedHashSet (java.util.LinkedHashSet)1 ResolvedArtifact (org.gradle.api.artifacts.ResolvedArtifact)1 ComponentIdentifier (org.gradle.api.artifacts.component.ComponentIdentifier)1 AttributeContainer (org.gradle.api.attributes.AttributeContainer)1 ArtifactVisitor (org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ArtifactVisitor)1 AttributeContainerInternal (org.gradle.api.internal.attributes.AttributeContainerInternal)1 ComponentFileArtifactIdentifier (org.gradle.internal.component.local.model.ComponentFileArtifactIdentifier)1 OpaqueComponentArtifactIdentifier (org.gradle.internal.component.local.model.OpaqueComponentArtifactIdentifier)1