Search in sources :

Example 1 with DirectoryFileTreeFactory

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);
}
Also used : ExecFactory(org.gradle.process.internal.ExecFactory) FileHasher(org.gradle.internal.hash.FileHasher) DefaultFileOperations(org.gradle.api.internal.file.DefaultFileOperations) DirectoryFileTreeFactory(org.gradle.api.internal.file.collections.DirectoryFileTreeFactory) ProviderFactory(org.gradle.api.provider.ProviderFactory) LoggingManager(org.gradle.api.logging.LoggingManager) FileOperations(org.gradle.api.internal.file.FileOperations) DefaultFileOperations(org.gradle.api.internal.file.DefaultFileOperations) Instantiator(org.gradle.internal.reflect.Instantiator) StreamHasher(org.gradle.internal.hash.StreamHasher) FileLookup(org.gradle.api.internal.file.FileLookup) File(java.io.File)

Example 2 with DirectoryFileTreeFactory

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)));
}
Also used : Expectations(org.jmock.Expectations) DefaultDirectoryFileTreeFactory(org.gradle.api.internal.file.collections.DefaultDirectoryFileTreeFactory) DirectoryFileTreeFactory(org.gradle.api.internal.file.collections.DirectoryFileTreeFactory) DefaultDirectoryFileTreeFactory(org.gradle.api.internal.file.collections.DefaultDirectoryFileTreeFactory) FileCollection(org.gradle.api.file.FileCollection) Collection(java.util.Collection) DirectoryFileTree(org.gradle.api.internal.file.collections.DirectoryFileTree) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)2 DirectoryFileTreeFactory (org.gradle.api.internal.file.collections.DirectoryFileTreeFactory)2 Collection (java.util.Collection)1 FileCollection (org.gradle.api.file.FileCollection)1 DefaultFileOperations (org.gradle.api.internal.file.DefaultFileOperations)1 FileLookup (org.gradle.api.internal.file.FileLookup)1 FileOperations (org.gradle.api.internal.file.FileOperations)1 DefaultDirectoryFileTreeFactory (org.gradle.api.internal.file.collections.DefaultDirectoryFileTreeFactory)1 DirectoryFileTree (org.gradle.api.internal.file.collections.DirectoryFileTree)1 LoggingManager (org.gradle.api.logging.LoggingManager)1 ProviderFactory (org.gradle.api.provider.ProviderFactory)1 FileHasher (org.gradle.internal.hash.FileHasher)1 StreamHasher (org.gradle.internal.hash.StreamHasher)1 Instantiator (org.gradle.internal.reflect.Instantiator)1 ExecFactory (org.gradle.process.internal.ExecFactory)1 Expectations (org.jmock.Expectations)1 Test (org.junit.Test)1