Search in sources :

Example 1 with FileCollectionDependency

use of org.gradle.api.artifacts.FileCollectionDependency in project gradle by gradle.

the class DefaultConfiguration method registerWatchPoints.

@Override
public void registerWatchPoints(FileSystemSubset.Builder builder) {
    for (Dependency dependency : getAllDependencies()) {
        if (dependency instanceof FileCollectionDependency) {
            FileCollection files = ((FileCollectionDependency) dependency).getFiles();
            ((FileCollectionInternal) files).registerWatchPoints(builder);
        }
    }
    super.registerWatchPoints(builder);
}
Also used : FileCollectionInternal(org.gradle.api.internal.file.FileCollectionInternal) Dependency(org.gradle.api.artifacts.Dependency) TaskDependency(org.gradle.api.tasks.TaskDependency) FileCollectionDependency(org.gradle.api.artifacts.FileCollectionDependency) AbstractTaskDependency(org.gradle.api.internal.tasks.AbstractTaskDependency) AbstractFileCollection(org.gradle.api.internal.file.AbstractFileCollection) FileCollection(org.gradle.api.file.FileCollection) FileCollectionDependency(org.gradle.api.artifacts.FileCollectionDependency)

Example 2 with FileCollectionDependency

use of org.gradle.api.artifacts.FileCollectionDependency in project gradle by gradle.

the class DefaultLocalConfigurationMetadataBuilder method addDependencies.

private void addDependencies(BuildableLocalConfigurationMetadata configurationMetadata, ConfigurationInternal configuration) {
    AttributeContainerInternal attributes = configuration.getAttributes();
    for (Dependency dependency : configuration.getDependencies()) {
        if (dependency instanceof ModuleDependency) {
            ModuleDependency moduleDependency = (ModuleDependency) dependency;
            configurationMetadata.addDependency(dependencyDescriptorFactory.createDependencyDescriptor(configurationMetadata.getComponentId(), configuration.getName(), attributes, moduleDependency));
        } else if (dependency instanceof FileCollectionDependency) {
            final FileCollectionDependency fileDependency = (FileCollectionDependency) dependency;
            configurationMetadata.addFiles(new DefaultLocalFileDependencyMetadata(fileDependency));
        } else {
            throw new IllegalArgumentException("Cannot convert dependency " + dependency + " to local component dependency metadata.");
        }
    }
}
Also used : ModuleDependency(org.gradle.api.artifacts.ModuleDependency) FileCollectionDependency(org.gradle.api.artifacts.FileCollectionDependency) ModuleDependency(org.gradle.api.artifacts.ModuleDependency) Dependency(org.gradle.api.artifacts.Dependency) FileCollectionDependency(org.gradle.api.artifacts.FileCollectionDependency) AttributeContainerInternal(org.gradle.api.internal.attributes.AttributeContainerInternal)

Example 3 with FileCollectionDependency

use of org.gradle.api.artifacts.FileCollectionDependency 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 4 with FileCollectionDependency

use of org.gradle.api.artifacts.FileCollectionDependency in project gradle by gradle.

the class DefaultDependenciesToModuleDescriptorConverter method addDependencies.

private void addDependencies(BuildableLocalComponentMetadata metaData, ConfigurationInternal configuration) {
    AttributeContainerInternal attributes = configuration.getAttributes();
    for (Dependency dependency : configuration.getDependencies()) {
        if (dependency instanceof ModuleDependency) {
            ModuleDependency moduleDependency = (ModuleDependency) dependency;
            metaData.addDependency(dependencyDescriptorFactory.createDependencyDescriptor(configuration.getName(), attributes, moduleDependency));
        } else if (dependency instanceof FileCollectionDependency) {
            final FileCollectionDependency fileDependency = (FileCollectionDependency) dependency;
            metaData.addFiles(configuration.getName(), new DefaultLocalFileDependencyMetadata(fileDependency));
        } else {
            throw new IllegalArgumentException("Cannot convert dependency " + dependency + " to local component dependency metadata.");
        }
    }
}
Also used : ModuleDependency(org.gradle.api.artifacts.ModuleDependency) FileCollectionDependency(org.gradle.api.artifacts.FileCollectionDependency) Dependency(org.gradle.api.artifacts.Dependency) ModuleDependency(org.gradle.api.artifacts.ModuleDependency) FileCollectionDependency(org.gradle.api.artifacts.FileCollectionDependency) AttributeContainerInternal(org.gradle.api.internal.attributes.AttributeContainerInternal)

Example 5 with FileCollectionDependency

use of org.gradle.api.artifacts.FileCollectionDependency in project gradle by gradle.

the class DefaultLenientConfiguration method visitArtifacts.

/**
     * Recursive, includes unsuccessfully resolved artifacts
     *
     * @param dependencySpec dependency spec
     */
private void visitArtifacts(Spec<? super Dependency> dependencySpec, SelectedArtifactResults artifactResults, SelectedFileDependencyResults fileDependencyResults, ArtifactVisitor visitor) {
    //avoid traversing the graph causing the full ResolvedDependency graph to be loaded for the most typical scenario
    if (dependencySpec == Specs.SATISFIES_ALL) {
        if (visitor.includeFiles()) {
            fileDependencyResults.getArtifacts().visit(visitor);
        }
        artifactResults.getArtifacts().visit(visitor);
        return;
    }
    if (visitor.includeFiles()) {
        for (Map.Entry<FileCollectionDependency, ResolvedArtifactSet> entry : fileDependencyResults.getFirstLevelFiles().entrySet()) {
            if (dependencySpec.isSatisfiedBy(entry.getKey())) {
                entry.getValue().visit(visitor);
            }
        }
    }
    CachingDirectedGraphWalker<DependencyGraphNodeResult, ResolvedArtifact> walker = new CachingDirectedGraphWalker<DependencyGraphNodeResult, ResolvedArtifact>(new ResolvedDependencyArtifactsGraph(visitor, fileDependencyResults));
    DependencyGraphNodeResult rootNode = loadTransientGraphResults(artifactResults).getRootNode();
    for (DependencyGraphNodeResult node : getFirstLevelNodes(dependencySpec)) {
        node.getArtifactsForIncomingEdge(rootNode).visit(visitor);
        walker.add(node);
    }
    walker.findValues();
}
Also used : DependencyGraphNodeResult(org.gradle.api.internal.artifacts.DependencyGraphNodeResult) ResolvedArtifact(org.gradle.api.artifacts.ResolvedArtifact) ResolvedArtifactSet(org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvedArtifactSet) Map(java.util.Map) FileCollectionDependency(org.gradle.api.artifacts.FileCollectionDependency) CachingDirectedGraphWalker(org.gradle.internal.graph.CachingDirectedGraphWalker)

Aggregations

FileCollectionDependency (org.gradle.api.artifacts.FileCollectionDependency)6 Map (java.util.Map)3 Dependency (org.gradle.api.artifacts.Dependency)3 ResolvedArtifactSet (org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvedArtifactSet)3 ArrayList (java.util.ArrayList)2 ModuleDependency (org.gradle.api.artifacts.ModuleDependency)2 ResolvedArtifact (org.gradle.api.artifacts.ResolvedArtifact)2 DependencyGraphNodeResult (org.gradle.api.internal.artifacts.DependencyGraphNodeResult)2 AttributeContainerInternal (org.gradle.api.internal.attributes.AttributeContainerInternal)2 CachingDirectedGraphWalker (org.gradle.internal.graph.CachingDirectedGraphWalker)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 FileCollection (org.gradle.api.file.FileCollection)1 CompositeResolvedArtifactSet (org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.CompositeResolvedArtifactSet)1 DynamicResolvedArtifactSet (org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.DynamicResolvedArtifactSet)1 FileDependencyArtifactSet (org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.FileDependencyArtifactSet)1 ParallelResolveArtifactSet (org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ParallelResolveArtifactSet)1 AbstractFileCollection (org.gradle.api.internal.file.AbstractFileCollection)1 FileCollectionInternal (org.gradle.api.internal.file.FileCollectionInternal)1 AbstractTaskDependency (org.gradle.api.internal.tasks.AbstractTaskDependency)1 TaskDependency (org.gradle.api.tasks.TaskDependency)1