use of org.gradle.api.internal.tasks.PropertyFileCollection in project gradle by gradle.
the class FileParameterUtils method resolveCompositeOutputFilePropertySpecs.
private static void resolveCompositeOutputFilePropertySpecs(final String ownerDisplayName, final String propertyName, Object unpackedValue, final TreeType outputType, FileCollectionFactory fileCollectionFactory, Consumer<OutputFilePropertySpec> consumer) {
if (unpackedValue instanceof Map) {
for (Map.Entry<?, ?> entry : ((Map<?, ?>) unpackedValue).entrySet()) {
Object key = entry.getKey();
if (key == null) {
throw new IllegalArgumentException(String.format("Mapped output property '%s' has null key", propertyName));
}
String id = key.toString();
FileCollectionInternal outputFiles = fileCollectionFactory.resolving(entry.getValue());
consumer.accept(new DefaultCacheableOutputFilePropertySpec(propertyName, "." + id, outputFiles, outputType));
}
} else {
FileCollectionInternal outputFileCollection = fileCollectionFactory.resolving(unpackedValue);
AtomicInteger index = new AtomicInteger(0);
outputFileCollection.visitStructure(new FileCollectionStructureVisitor() {
@Override
public void visitCollection(FileCollectionInternal.Source source, Iterable<File> contents) {
for (File content : contents) {
FileCollectionInternal outputFiles = fileCollectionFactory.fixed(content);
consumer.accept(new DefaultCacheableOutputFilePropertySpec(propertyName, "$" + index.incrementAndGet(), outputFiles, outputType));
}
}
@Override
public void visitGenericFileTree(FileTreeInternal fileTree, FileSystemMirroringFileTree sourceTree) {
failOnInvalidOutputType(fileTree);
}
@Override
public void visitFileTreeBackedByFile(File file, FileTreeInternal fileTree, FileSystemMirroringFileTree sourceTree) {
failOnInvalidOutputType(fileTree);
}
@Override
public void visitFileTree(File root, PatternSet patterns, FileTreeInternal fileTree) {
// We could support an unfiltered DirectoryFileTree here as a cacheable root,
// but because @OutputDirectory also doesn't support it we choose not to.
consumer.accept(new DirectoryTreeOutputFilePropertySpec(propertyName + "$" + index.incrementAndGet(), new PropertyFileCollection(ownerDisplayName, propertyName, "output", fileTree), root));
}
});
}
}
use of org.gradle.api.internal.tasks.PropertyFileCollection in project gradle by gradle.
the class GetInputFilesVisitor method visitInputFileProperty.
@Override
public void visitInputFileProperty(final String propertyName, boolean optional, boolean skipWhenEmpty, DirectorySensitivity directorySensitivity, LineEndingSensitivity lineEndingSensitivity, boolean incremental, @Nullable Class<? extends FileNormalizer> fileNormalizer, PropertyValue value, InputFilePropertyType filePropertyType) {
FileCollectionInternal actualValue = FileParameterUtils.resolveInputFileValue(fileCollectionFactory, filePropertyType, value);
Class<? extends FileNormalizer> normalizer = FileParameterUtils.normalizerOrDefault(fileNormalizer);
specs.add(new DefaultInputFilePropertySpec(propertyName, normalizer, new PropertyFileCollection(ownerDisplayName, propertyName, "input", actualValue), value, skipWhenEmpty, incremental, normalizeDirectorySensitivity(normalizer, directorySensitivity), lineEndingSensitivity));
if (skipWhenEmpty) {
hasSourceFiles = true;
}
}
Aggregations