private Set<GradleLibrary> getLibrariesForFileDependencies( Configuration configuration, LibraryScope scope) { Set<GradleLibrary> libraries = new LinkedHashSet<GradleLibrary>(); for (Dependency dependency : configuration.getIncoming().getDependencies()) { if (dependency instanceof FileCollectionDependency) { FileCollectionDependency fileDependency = (FileCollectionDependency) dependency; for (File file : fileDependency.resolve()) { libraries.add( new GradleLibrary(fileDependency.getGroup(), file, scope)); } } else if (dependency instanceof ProjectDependency) { ProjectDependency projectDependency = (ProjectDependency) dependency; libraries.addAll(getLibrariesForFileDependencies( projectDependency.getProjectConfiguration(), scope)); } } return libraries; }
/** * Recursive, includes unsuccessfully resolved artifacts * * @param dependencySpec dependency spec */ private void visitArtifacts(Spec<? super Dependency> dependencySpec, AttributeContainerInternal requestedAttributes, SelectedArtifactResults artifactResults, SelectedFileDependencyResults fileDependencyResults, ArtifactVisitor visitor) { ArtifactVisitor transformingVisitor = artifactTransformer.visitor(visitor, requestedAttributes); //this is not very nice might be good enough until we get rid of ResolvedConfiguration and friends //avoid traversing the graph causing the full ResolvedDependency graph to be loaded for the most typical scenario if (dependencySpec == Specs.SATISFIES_ALL) { if (transformingVisitor.includeFiles()) { fileDependencyResults.getFiles().visit(transformingVisitor); } artifactResults.getArtifacts().visit(transformingVisitor); return; } if (transformingVisitor.includeFiles()) { for (Map.Entry<FileCollectionDependency, ResolvedArtifactSet> entry: fileDependencyResults.getFirstLevelFiles().entrySet()) { if (dependencySpec.isSatisfiedBy(entry.getKey())) { entry.getValue().visit(transformingVisitor); } } } CachingDirectedGraphWalker<DependencyGraphNodeResult, ResolvedArtifact> walker = new CachingDirectedGraphWalker<DependencyGraphNodeResult, ResolvedArtifact>(new ResolvedDependencyArtifactsGraph(transformingVisitor, fileDependencyResults)); DependencyGraphNodeResult rootNode = loadTransientGraphResults(artifactResults).getRootNode(); for (DependencyGraphNodeResult node : getFirstLevelNodes(dependencySpec)) { node.getArtifactsForIncomingEdge(rootNode).visit(transformingVisitor); walker.add(node); } walker.findValues(); }
private void addDependencies(BuildableLocalComponentMetadata metaData, ConfigurationInternal configuration) { AttributeContainerInternal attributes = configuration.getAttributes().asImmutable(); 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."); } } }
@Override public void registerWatchPoints(FileSystemSubset.Builder builder) { for (Dependency dependency : allDependencies) { if (dependency instanceof FileCollectionDependency) { FileCollection files = ((FileCollectionDependency) dependency).getFiles(); ((FileCollectionInternal) files).registerWatchPoints(builder); } } super.registerWatchPoints(builder); }
DefaultLocalFileDependencyMetadata(FileCollectionDependency fileDependency) { this.fileDependency = fileDependency; }
@Override public FileCollectionDependency getSource() { return fileDependency; }
@Override public Map<FileCollectionDependency, ResolvedArtifactSet> getFirstLevelFiles() { return rootFiles; }
/** * Returns the direct dependencies of the root node. */ Map<FileCollectionDependency, ResolvedArtifactSet> getFirstLevelFiles();
/** * Remove this. */ FileCollectionDependency getSource();