Search in sources :

Example 1 with DefaultFileOperations

use of org.gradle.api.internal.file.DefaultFileOperations 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);
    DirectoryFileTreeFactory directoryFileTreeFactory = services.get(DirectoryFileTreeFactory.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);
        } else {
            fileOperations = new DefaultFileOperations(fileLookup.getFileResolver(), null, null, instantiator, fileLookup, directoryFileTreeFactory);
        }
    }
    processOperations = (ProcessOperations) fileOperations;
}
Also used : DefaultFileOperations(org.gradle.api.internal.file.DefaultFileOperations) DirectoryFileTreeFactory(org.gradle.api.internal.file.collections.DirectoryFileTreeFactory) 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) FileLookup(org.gradle.api.internal.file.FileLookup) File(java.io.File)

Aggregations

File (java.io.File)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 DirectoryFileTreeFactory (org.gradle.api.internal.file.collections.DirectoryFileTreeFactory)1 LoggingManager (org.gradle.api.logging.LoggingManager)1 Instantiator (org.gradle.internal.reflect.Instantiator)1