use of org.gradle.api.internal.file.collections.DirectoryFileTreeFactory in project gradle by gradle.
the class DefaultScript method init.
@Override
public void init(final Object target, ServiceRegistry services) {
super.init(target, services);
this.__scriptServices = services;
loggingManager = services.get(LoggingManager.class);
Instantiator instantiator = services.get(Instantiator.class);
FileLookup fileLookup = services.get(FileLookup.class);
ExecFactory execFactory = services.get(ExecFactory.class);
DirectoryFileTreeFactory directoryFileTreeFactory = services.get(DirectoryFileTreeFactory.class);
StreamHasher streamHasher = services.get(StreamHasher.class);
FileHasher fileHasher = services.get(FileHasher.class);
if (target instanceof FileOperations) {
fileOperations = (FileOperations) target;
} else {
File sourceFile = getScriptSource().getResource().getLocation().getFile();
if (sourceFile != null) {
fileOperations = new DefaultFileOperations(fileLookup.getFileResolver(sourceFile.getParentFile()), null, null, instantiator, fileLookup, directoryFileTreeFactory, streamHasher, fileHasher, execFactory);
} else {
fileOperations = new DefaultFileOperations(fileLookup.getFileResolver(), null, null, instantiator, fileLookup, directoryFileTreeFactory, streamHasher, fileHasher, execFactory);
}
}
processOperations = (ProcessOperations) fileOperations;
providerFactory = services.get(ProviderFactory.class);
}
use of org.gradle.api.internal.file.collections.DirectoryFileTreeFactory in project gradle by gradle.
the class CompositeFileCollectionTest method getAsFileTreesReturnsUnionOfFileTrees.
@Test
public void getAsFileTreesReturnsUnionOfFileTrees() {
final DirectoryFileTreeFactory directoryFileTreeFactory = new DefaultDirectoryFileTreeFactory();
final DirectoryFileTree set1 = directoryFileTreeFactory.create(new File("dir1").getAbsoluteFile());
final DirectoryFileTree set2 = directoryFileTreeFactory.create(new File("dir2").getAbsoluteFile());
context.checking(new Expectations() {
{
oneOf(source1).getAsFileTrees();
will(returnValue(toList((Object) set1)));
oneOf(source2).getAsFileTrees();
will(returnValue(toList((Object) set2)));
}
});
assertThat(collection.getAsFileTrees(), equalTo((Collection) toList(set1, set2)));
}
Aggregations