Search in sources :

Example 1 with ParallelResolveArtifactSet

use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ParallelResolveArtifactSet in project gradle by gradle.

the class DefaultVisitedFileDependencyResults method select.

@Override
public SelectedFileDependencyResults select(Spec<? super ComponentIdentifier> componentFilter, VariantSelector selector) {
    // Wrap each file dependency in a set that performs variant selection and transformation
    // Also merge together the artifact sets for each configuration node
    ImmutableMap.Builder<Long, ResolvedArtifactSet> filesByConfigBuilder = ImmutableMap.builder();
    List<DynamicResolvedArtifactSet> allArtifacts = Lists.newArrayList();
    for (Long key : filesByNodeId.keySet()) {
        Set<FileDependencyArtifactSet> artifactsForConfiguration = filesByNodeId.get(key);
        List<DynamicResolvedArtifactSet> selectedArtifactsForConfiguration = new ArrayList<DynamicResolvedArtifactSet>(artifactsForConfiguration.size());
        for (FileDependencyArtifactSet artifactSet : artifactsForConfiguration) {
            selectedArtifactsForConfiguration.add(artifactSet.select(componentFilter, selector));
        }
        filesByConfigBuilder.put(key, CompositeArtifactSet.of(selectedArtifactsForConfiguration));
        allArtifacts.addAll(selectedArtifactsForConfiguration);
    }
    ResolvedArtifactSet allFiles = new ParallelResolveArtifactSet(CompositeDynamicArtifactSet.create(allArtifacts), buildOperationProcessor);
    ImmutableMap.Builder<FileCollectionDependency, ResolvedArtifactSet> rootFilesBuilder = ImmutableMap.builder();
    for (Map.Entry<FileCollectionDependency, FileDependencyArtifactSet> entry : rootFiles.entrySet()) {
        rootFilesBuilder.put(entry.getKey(), entry.getValue().select(componentFilter, selector));
    }
    ImmutableMap<Long, ResolvedArtifactSet> filesByConfig = filesByConfigBuilder.build();
    return new DefaultFileDependencyResults(rootFilesBuilder.build(), allFiles, filesByConfig);
}
Also used : ResolvedArtifactSet(org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvedArtifactSet) DynamicResolvedArtifactSet(org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.DynamicResolvedArtifactSet) ArrayList(java.util.ArrayList) FileDependencyArtifactSet(org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.FileDependencyArtifactSet) FileCollectionDependency(org.gradle.api.artifacts.FileCollectionDependency) ImmutableMap(com.google.common.collect.ImmutableMap) ParallelResolveArtifactSet(org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ParallelResolveArtifactSet) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) DynamicResolvedArtifactSet(org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.DynamicResolvedArtifactSet)

Example 2 with ParallelResolveArtifactSet

use of org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ParallelResolveArtifactSet in project gradle by gradle.

the class DependencyResolvingClasspath method getFiles.

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

        @Override
        public void visitArtifact(String variantName, AttributeContainer variantAttributes, ResolvableArtifact artifact) {
            result.add(artifact.getFile());
        }

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

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

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

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

Aggregations

ParallelResolveArtifactSet (org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ParallelResolveArtifactSet)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 FileCollectionDependency (org.gradle.api.artifacts.FileCollectionDependency)1 ComponentArtifactIdentifier (org.gradle.api.artifacts.component.ComponentArtifactIdentifier)1 AttributeContainer (org.gradle.api.attributes.AttributeContainer)1 ArtifactVisitor (org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ArtifactVisitor)1 DynamicResolvedArtifactSet (org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.DynamicResolvedArtifactSet)1 FileDependencyArtifactSet (org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.FileDependencyArtifactSet)1 ResolvableArtifact (org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvableArtifact)1 ResolvedArtifactSet (org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvedArtifactSet)1