Search in sources :

Example 1 with ResolvedFileCollectionVisitor

use of org.gradle.api.internal.artifacts.ivyservice.ResolvedFileCollectionVisitor in project gradle by gradle.

the class ArtifactSetToFileCollectionFactory method asFileCollection.

/**
 * Presents the contents of the given artifacts as a partial {@link FileCollectionInternal} implementation.
 *
 * <p>This produces only a minimal implementation to use for artifact sets loaded from the configuration cache
 * Over time, this should be merged with the FileCollection implementation in DefaultConfiguration
 */
public FileCollectionInternal asFileCollection(ResolvedArtifactSet artifacts) {
    return new AbstractFileCollection() {

        @Override
        public String getDisplayName() {
            return "files";
        }

        @Override
        protected void visitContents(FileCollectionStructureVisitor visitor) {
            ResolvedFileCollectionVisitor collectingVisitor = new ResolvedFileCollectionVisitor(visitor);
            ParallelResolveArtifactSet.wrap(artifacts, buildOperationExecutor).visit(collectingVisitor);
            if (!collectingVisitor.getFailures().isEmpty()) {
                throw UncheckedException.throwAsUncheckedException(collectingVisitor.getFailures().iterator().next());
            }
        }
    };
}
Also used : AbstractFileCollection(org.gradle.api.internal.file.AbstractFileCollection) FileCollectionStructureVisitor(org.gradle.api.internal.file.FileCollectionStructureVisitor) ResolvedFileCollectionVisitor(org.gradle.api.internal.artifacts.ivyservice.ResolvedFileCollectionVisitor)

Aggregations

ResolvedFileCollectionVisitor (org.gradle.api.internal.artifacts.ivyservice.ResolvedFileCollectionVisitor)1 AbstractFileCollection (org.gradle.api.internal.file.AbstractFileCollection)1 FileCollectionStructureVisitor (org.gradle.api.internal.file.FileCollectionStructureVisitor)1