Java Code Examples for org.gradle.api.internal.file.FileOperations

The following examples show how to use org.gradle.api.internal.file.FileOperations. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public IncrementalCompilerFactory(FileOperations fileOperations, String compileDisplayName, CleaningJavaCompiler cleaningJavaCompiler,
                                  List<Object> source, CompileCaches compileCaches, IncrementalTaskInputsInternal inputs) {
    this.inputs = inputs;
    //bunch of services that enable incremental java compilation.
    Hasher hasher = new DefaultHasher(); //TODO SF use caching hasher
    ClassDependenciesAnalyzer analyzer = new CachingClassDependenciesAnalyzer(new DefaultClassDependenciesAnalyzer(), hasher, compileCaches.getClassAnalysisCache());
    JarSnapshotter jarSnapshotter = new CachingJarSnapshotter(hasher, analyzer, compileCaches.getJarSnapshotCache(), inputs.getInputFilesSnapshot());

    JarClasspathSnapshotMaker jarClasspathSnapshotMaker = new JarClasspathSnapshotMaker(compileCaches.getLocalJarClasspathSnapshotStore(), new JarClasspathSnapshotFactory(jarSnapshotter), new ClasspathJarFinder(fileOperations));
    CompilationSourceDirs sourceDirs = new CompilationSourceDirs(source);
    SourceToNameConverter sourceToNameConverter = new SourceToNameConverter(sourceDirs); //TODO SF replace with converter that parses input source class
    RecompilationSpecProvider recompilationSpecProvider = new RecompilationSpecProvider(sourceToNameConverter, fileOperations);
    ClassSetAnalysisUpdater classSetAnalysisUpdater = new ClassSetAnalysisUpdater(compileCaches.getLocalClassSetAnalysisStore(), fileOperations, analyzer);
    IncrementalCompilationInitializer compilationInitializer = new IncrementalCompilationInitializer(fileOperations);
    incrementalSupport = new IncrementalCompilerDecorator(jarClasspathSnapshotMaker, compileCaches, compilationInitializer,
            cleaningJavaCompiler, compileDisplayName, recompilationSpecProvider, classSetAnalysisUpdater, sourceDirs);
}
 
Example 2
public FileCollectionBackedArchiveTextResource(final FileOperations fileOperations,
                                               final TemporaryFileProvider tempFileProvider,
                                               final FileCollection fileCollection,
                                               final String path, Charset charset) {
    super(tempFileProvider, new LazilyInitializedFileTree() {
        @Override
        public FileTree createDelegate() {
            File archiveFile = fileCollection.getSingleFile();
            String fileExtension = Files.getFileExtension(archiveFile.getName());
            FileTree archiveContents = fileExtension.equals("jar") || fileExtension.equals("zip")
                    ? fileOperations.zipTree(archiveFile) : fileOperations.tarTree(archiveFile);
            PatternSet patternSet = new PatternSet();
            patternSet.include(path);
            return archiveContents.matching(patternSet);
        }
        public TaskDependency getBuildDependencies() {
            return fileCollection.getBuildDependencies();
        }
    }, charset);
}
 
Example 3
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);
    if (target instanceof FileOperations) {
        fileOperations = (FileOperations) target;
    } else if (getScriptSource().getResource().getFile() != null) {
        fileOperations = new DefaultFileOperations(fileLookup.getFileResolver(getScriptSource().getResource().getFile().getParentFile()), null, null, instantiator, fileLookup);
    } else {
        fileOperations = new DefaultFileOperations(fileLookup.getFileResolver(), null, null, instantiator, fileLookup);
    }

    processOperations = (ProcessOperations) fileOperations;
}
 
Example 4
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);
    if (target instanceof FileOperations) {
        fileOperations = (FileOperations) target;
    } else if (getScriptSource().getResource().getFile() != null) {
        fileOperations = new DefaultFileOperations(fileLookup.getFileResolver(getScriptSource().getResource().getFile().getParentFile()), null, null, instantiator, fileLookup);
    } else {
        fileOperations = new DefaultFileOperations(fileLookup.getFileResolver(), null, null, instantiator, fileLookup);
    }

    processOperations = (ProcessOperations) fileOperations;
}
 
Example 5
public IncrementalCompilerFactory(FileOperations fileOperations, String compileDisplayName, CleaningJavaCompiler cleaningJavaCompiler,
                                  List<Object> source, CompileCaches compileCaches, IncrementalTaskInputsInternal inputs) {
    this.inputs = inputs;
    //bunch of services that enable incremental java compilation.
    Hasher hasher = new DefaultHasher(); //TODO SF use caching hasher
    ClassDependenciesAnalyzer analyzer = new CachingClassDependenciesAnalyzer(new DefaultClassDependenciesAnalyzer(), hasher, compileCaches.getClassAnalysisCache());
    JarSnapshotter jarSnapshotter = new CachingJarSnapshotter(hasher, analyzer, compileCaches.getJarSnapshotCache(), inputs.getInputFilesSnapshot());

    JarClasspathSnapshotMaker jarClasspathSnapshotMaker = new JarClasspathSnapshotMaker(compileCaches.getLocalJarClasspathSnapshotStore(), new JarClasspathSnapshotFactory(jarSnapshotter), new ClasspathJarFinder(fileOperations));
    CompilationSourceDirs sourceDirs = new CompilationSourceDirs(source);
    SourceToNameConverter sourceToNameConverter = new SourceToNameConverter(sourceDirs); //TODO SF replace with converter that parses input source class
    RecompilationSpecProvider recompilationSpecProvider = new RecompilationSpecProvider(sourceToNameConverter, fileOperations);
    ClassSetAnalysisUpdater classSetAnalysisUpdater = new ClassSetAnalysisUpdater(compileCaches.getLocalClassSetAnalysisStore(), fileOperations, analyzer);
    IncrementalCompilationInitializer compilationInitializer = new IncrementalCompilationInitializer(fileOperations);
    incrementalSupport = new IncrementalCompilerDecorator(jarClasspathSnapshotMaker, compileCaches, compilationInitializer,
            cleaningJavaCompiler, compileDisplayName, recompilationSpecProvider, classSetAnalysisUpdater, sourceDirs);
}
 
Example 6
public FileCollectionBackedArchiveTextResource(final FileOperations fileOperations,
                                               final TemporaryFileProvider tempFileProvider,
                                               final FileCollection fileCollection,
                                               final String path, Charset charset) {
    super(tempFileProvider, new LazilyInitializedFileTree() {
        @Override
        public FileTree createDelegate() {
            File archiveFile = fileCollection.getSingleFile();
            String fileExtension = Files.getFileExtension(archiveFile.getName());
            FileTree archiveContents = fileExtension.equals("jar") || fileExtension.equals("zip")
                    ? fileOperations.zipTree(archiveFile) : fileOperations.tarTree(archiveFile);
            PatternSet patternSet = new PatternSet();
            patternSet.include(path);
            return archiveContents.matching(patternSet);
        }
        public TaskDependency getBuildDependencies() {
            return fileCollection.getBuildDependencies();
        }
    }, charset);
}
 
Example 7
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);
    if (target instanceof FileOperations) {
        fileOperations = (FileOperations) target;
    } else if (getScriptSource().getResource().getFile() != null) {
        fileOperations = new DefaultFileOperations(fileLookup.getFileResolver(getScriptSource().getResource().getFile().getParentFile()), null, null, instantiator, fileLookup);
    } else {
        fileOperations = new DefaultFileOperations(fileLookup.getFileResolver(), null, null, instantiator, fileLookup);
    }

    processOperations = (ProcessOperations) fileOperations;
}
 
Example 8
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);
    if (target instanceof FileOperations) {
        fileOperations = (FileOperations) target;
    } else if (getScriptSource().getResource().getFile() != null) {
        fileOperations = new DefaultFileOperations(fileLookup.getFileResolver(getScriptSource().getResource().getFile().getParentFile()), null, null, instantiator, fileLookup);
    } else {
        fileOperations = new DefaultFileOperations(fileLookup.getFileResolver(), null, null, instantiator, fileLookup);
    }

    processOperations = (ProcessOperations) fileOperations;
}
 
Example 9
@TaskAction
protected void compile(IncrementalTaskInputs inputs) {
    if (!compileOptions.isIncremental()) {
        compile();
        return;
    }

    SingleMessageLogger.incubatingFeatureUsed("Incremental java compilation");

    DefaultJavaCompileSpec spec = createSpec();
    final CacheRepository repository1 = getCacheRepository();
    final JavaCompile javaCompile1 = this;
    final GeneralCompileCaches generalCaches1 = getGeneralCompileCaches();
    CompileCaches compileCaches = new CompileCaches() {
        private final CacheRepository repository = repository1;
        private final JavaCompile javaCompile = javaCompile1;
        private final GeneralCompileCaches generalCaches = generalCaches1;

        public ClassAnalysisCache getClassAnalysisCache() {
            return generalCaches.getClassAnalysisCache();
        }

        public JarSnapshotCache getJarSnapshotCache() {
            return generalCaches.getJarSnapshotCache();
        }

        public LocalJarClasspathSnapshotStore getLocalJarClasspathSnapshotStore() {
            return new LocalJarClasspathSnapshotStore(repository, javaCompile);
        }

        public LocalClassSetAnalysisStore getLocalClassSetAnalysisStore() {
            return new LocalClassSetAnalysisStore(repository, javaCompile);
        }
    };
    IncrementalCompilerFactory factory = new IncrementalCompilerFactory(
            (FileOperations) getProject(), getPath(), createCompiler(spec), source, compileCaches, (IncrementalTaskInputsInternal) inputs);
    Compiler<JavaCompileSpec> compiler = factory.createCompiler();
    performCompilation(spec, compiler);
}
 
Example 10
Source Project: pushfish-android   Source File: Compile.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
private boolean maybeCompileIncrementally(IncrementalTaskInputs inputs) {
    if (!compileOptions.isIncremental()) {
        return false;
    }
    //hack
    List<File> sourceDirs = getSourceDirs();
    if (sourceDirs.isEmpty()) {
        LOG.lifecycle("{} cannot run incrementally because Gradle cannot infer the source directories.", getPath());
        return false;
    }
    if (!inputs.isIncremental()) {
        LOG.lifecycle("{} is not incremental (e.g. outputs have changed, no previous execution, etc). Using regular compile.", getPath());
        return false;
    }
    ClassDependencyInfoSerializer dependencyInfoSerializer = getDependencyInfoSerializer();
    if (!dependencyInfoSerializer.isInfoAvailable()) {
        //TODO SF let's unit test a scenario when after regular compilation incremental compilation is scheduled
        LOG.lifecycle("{} is not incremental because there is no class dependency data left from previous incremental build.", getPath());
        return false;
    }

    SingleMessageLogger.incubatingFeatureUsed("Incremental java compilation");

    SelectiveJavaCompiler compiler = new SelectiveJavaCompiler(javaCompiler, getProject().fileTree(getDestinationDir()));
    SelectiveCompilation selectiveCompilation = new SelectiveCompilation(inputs, getSource(), getClasspath(), getDestinationDir(),
            dependencyInfoSerializer, getJarSnapshotCache(), compiler, sourceDirs, (FileOperations) getProject());

    if (!selectiveCompilation.getCompilationNeeded()) {
        LOG.lifecycle("{} does not require recompilation. Skipping the compiler.", getPath());
        return true;
    }

    Clock clock = new Clock();
    performCompilation(selectiveCompilation.getSource(), selectiveCompilation.getClasspath(), selectiveCompilation.getFullRebuildRequired()? cleaningCompiler : compiler);
    LOG.lifecycle("{} - incremental compilation took {}", getPath(), clock.getTime());

    return true;
}
 
Example 11
public SelectiveCompilation(IncrementalTaskInputs inputs, FileTree source, FileCollection compileClasspath, final File compileDestination,
                            final ClassDependencyInfoSerializer dependencyInfoSerializer, final JarSnapshotCache jarSnapshotCache, final SelectiveJavaCompiler compiler,
                            Iterable<File> sourceDirs, final FileOperations operations) {
    this.operations = operations;
    this.jarSnapshotFeeder = new JarSnapshotFeeder(jarSnapshotCache, new JarSnapshotter(new DefaultHasher()));
    this.compiler = compiler;

    Clock clock = new Clock();
    final InputOutputMapper mapper = new InputOutputMapper(sourceDirs, compileDestination);

    //load dependency info
    final ClassDependencyInfo dependencyInfo = dependencyInfoSerializer.readInfo();

    //including only source java classes that were changed
    final PatternSet changedSourceOnly = new PatternSet();
    InputFileDetailsAction action = new InputFileDetailsAction(mapper, compiler, changedSourceOnly, dependencyInfo);
    inputs.outOfDate(action);
    inputs.removed(action);
    if (fullRebuildNeeded != null) {
        LOG.lifecycle("Stale classes detection completed in {}. Rebuild needed: {}.", clock.getTime(), fullRebuildNeeded);
        this.classpath = compileClasspath;
        this.source = source;
        return;
    }

    compiler.deleteStaleClasses();
    Set<File> filesToCompile = source.matching(changedSourceOnly).getFiles();
    if (filesToCompile.isEmpty()) {
        this.compilationNeeded = false;
        this.classpath = compileClasspath;
        this.source = source;
    } else {
        this.classpath = compileClasspath.plus(new SimpleFileCollection(compileDestination));
        this.source = source.matching(changedSourceOnly);
    }
    LOG.lifecycle("Stale classes detection completed in {}. Compile include patterns: {}.", clock.getTime(), changedSourceOnly.getIncludes());
}
 
Example 12
Source Project: playframework   Source File: JavaScriptMinify.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void visitFile(final FileVisitDetails fileDetails) {
    final File outputFileDir = new File(destinationDir.get().getAsFile(), fileDetails.getRelativePath().getParent().getPathString());

    // Copy the raw form
    FileOperations fileOperations = ((ProjectInternal) getProject()).getFileOperations();
    fileOperations.copy(copySpec -> copySpec.from(fileDetails.getFile()).into(outputFileDir));

    // Capture the relative file
    relativeFiles.add(new RelativeFile(fileDetails.getFile(), fileDetails.getRelativePath()));
}
 
Example 13
@TaskAction
protected void compile(IncrementalTaskInputs inputs) {
    if (!compileOptions.isIncremental()) {
        compile();
        return;
    }

    SingleMessageLogger.incubatingFeatureUsed("Incremental java compilation");

    DefaultJavaCompileSpec spec = createSpec();
    final CacheRepository repository1 = getCacheRepository();
    final JavaCompile javaCompile1 = this;
    final GeneralCompileCaches generalCaches1 = getGeneralCompileCaches();
    CompileCaches compileCaches = new CompileCaches() {
        private final CacheRepository repository = repository1;
        private final JavaCompile javaCompile = javaCompile1;
        private final GeneralCompileCaches generalCaches = generalCaches1;

        public ClassAnalysisCache getClassAnalysisCache() {
            return generalCaches.getClassAnalysisCache();
        }

        public JarSnapshotCache getJarSnapshotCache() {
            return generalCaches.getJarSnapshotCache();
        }

        public LocalJarClasspathSnapshotStore getLocalJarClasspathSnapshotStore() {
            return new LocalJarClasspathSnapshotStore(repository, javaCompile);
        }

        public LocalClassSetAnalysisStore getLocalClassSetAnalysisStore() {
            return new LocalClassSetAnalysisStore(repository, javaCompile);
        }
    };
    IncrementalCompilerFactory factory = new IncrementalCompilerFactory(
            (FileOperations) getProject(), getPath(), createCompiler(spec), source, compileCaches, (IncrementalTaskInputsInternal) inputs);
    Compiler<JavaCompileSpec> compiler = factory.createCompiler();
    performCompilation(spec, compiler);
}
 
Example 14
Source Project: Pushjet-Android   Source File: Compile.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
private boolean maybeCompileIncrementally(IncrementalTaskInputs inputs) {
    if (!compileOptions.isIncremental()) {
        return false;
    }
    //hack
    List<File> sourceDirs = getSourceDirs();
    if (sourceDirs.isEmpty()) {
        LOG.lifecycle("{} cannot run incrementally because Gradle cannot infer the source directories.", getPath());
        return false;
    }
    if (!inputs.isIncremental()) {
        LOG.lifecycle("{} is not incremental (e.g. outputs have changed, no previous execution, etc). Using regular compile.", getPath());
        return false;
    }
    ClassDependencyInfoSerializer dependencyInfoSerializer = getDependencyInfoSerializer();
    if (!dependencyInfoSerializer.isInfoAvailable()) {
        //TODO SF let's unit test a scenario when after regular compilation incremental compilation is scheduled
        LOG.lifecycle("{} is not incremental because there is no class dependency data left from previous incremental build.", getPath());
        return false;
    }

    SingleMessageLogger.incubatingFeatureUsed("Incremental java compilation");

    SelectiveJavaCompiler compiler = new SelectiveJavaCompiler(javaCompiler, getProject().fileTree(getDestinationDir()));
    SelectiveCompilation selectiveCompilation = new SelectiveCompilation(inputs, getSource(), getClasspath(), getDestinationDir(),
            dependencyInfoSerializer, getJarSnapshotCache(), compiler, sourceDirs, (FileOperations) getProject());

    if (!selectiveCompilation.getCompilationNeeded()) {
        LOG.lifecycle("{} does not require recompilation. Skipping the compiler.", getPath());
        return true;
    }

    Clock clock = new Clock();
    performCompilation(selectiveCompilation.getSource(), selectiveCompilation.getClasspath(), selectiveCompilation.getFullRebuildRequired()? cleaningCompiler : compiler);
    LOG.lifecycle("{} - incremental compilation took {}", getPath(), clock.getTime());

    return true;
}
 
Example 15
public SelectiveCompilation(IncrementalTaskInputs inputs, FileTree source, FileCollection compileClasspath, final File compileDestination,
                            final ClassDependencyInfoSerializer dependencyInfoSerializer, final JarSnapshotCache jarSnapshotCache, final SelectiveJavaCompiler compiler,
                            Iterable<File> sourceDirs, final FileOperations operations) {
    this.operations = operations;
    this.jarSnapshotFeeder = new JarSnapshotFeeder(jarSnapshotCache, new JarSnapshotter(new DefaultHasher()));
    this.compiler = compiler;

    Clock clock = new Clock();
    final InputOutputMapper mapper = new InputOutputMapper(sourceDirs, compileDestination);

    //load dependency info
    final ClassDependencyInfo dependencyInfo = dependencyInfoSerializer.readInfo();

    //including only source java classes that were changed
    final PatternSet changedSourceOnly = new PatternSet();
    InputFileDetailsAction action = new InputFileDetailsAction(mapper, compiler, changedSourceOnly, dependencyInfo);
    inputs.outOfDate(action);
    inputs.removed(action);
    if (fullRebuildNeeded != null) {
        LOG.lifecycle("Stale classes detection completed in {}. Rebuild needed: {}.", clock.getTime(), fullRebuildNeeded);
        this.classpath = compileClasspath;
        this.source = source;
        return;
    }

    compiler.deleteStaleClasses();
    Set<File> filesToCompile = source.matching(changedSourceOnly).getFiles();
    if (filesToCompile.isEmpty()) {
        this.compilationNeeded = false;
        this.classpath = compileClasspath;
        this.source = source;
    } else {
        this.classpath = compileClasspath.plus(new SimpleFileCollection(compileDestination));
        this.source = source.matching(changedSourceOnly);
    }
    LOG.lifecycle("Stale classes detection completed in {}. Compile include patterns: {}.", clock.getTime(), changedSourceOnly.getIncludes());
}
 
Example 16
public void execute(final FileCollection source, File destDir, boolean use, String windowTitle, String docTitle, String header, String footer, String overview, boolean includePrivate, final Set<Groovydoc.Link> links, final Iterable<File> groovyClasspath, Iterable<File> classpath, Project project) {

        final File tmpDir = new File(project.getBuildDir(), "tmp/groovydoc");
        FileOperations fileOperations = (ProjectInternal) project;
        fileOperations.delete(tmpDir);
        fileOperations.copy(new Action<CopySpec>() {
            public void execute(CopySpec copySpec) {
                copySpec.from(source).into(tmpDir);
            }
        });

        final Map<String, Object> args = Maps.newLinkedHashMap();
        args.put("sourcepath", tmpDir.toString());
        args.put("destdir", destDir);
        args.put("use", use);
        args.put("private", includePrivate);
        putIfNotNull(args, "windowtitle", windowTitle);
        putIfNotNull(args, "doctitle", docTitle);
        putIfNotNull(args, "header", header);
        putIfNotNull(args, "footer", footer);
        putIfNotNull(args, "overview", overview);

        List<File> combinedClasspath = ImmutableList.<File>builder()
                .addAll(classpath)
                .addAll(groovyClasspath)
                .build();

        ant.withClasspath(combinedClasspath).execute(new Closure<Object>(this, this) {
            @SuppressWarnings("UnusedDeclaration")
            public Object doCall(Object it) {
                final GroovyObjectSupport antBuilder = (GroovyObjectSupport) it;

                antBuilder.invokeMethod("taskdef", ImmutableMap.of(
                        "name", "groovydoc",
                        "classname", "org.codehaus.groovy.ant.Groovydoc"
                ));

                antBuilder.invokeMethod("groovydoc", new Object[]{args, new Closure<Object>(this, this) {
                    public Object doCall(Object ignore) {
                        for (Groovydoc.Link link : links) {
                            antBuilder.invokeMethod("link", new Object[]{
                                    ImmutableMap.of(
                                            "packages", Joiner.on(",").join(link.getPackages()),
                                            "href", link.getUrl()
                                    )
                            });
                        }

                        return null;
                    }
                }});

                return null;
            }
        });
    }
 
Example 17
public JarChangeProcessor(FileOperations fileOperations, JarClasspathSnapshot jarClasspathSnapshot, PreviousCompilation previousCompilation) {
    this.fileOperations = fileOperations;
    this.jarClasspathSnapshot = jarClasspathSnapshot;
    this.previousCompilation = previousCompilation;
}
 
Example 18
public ClasspathJarFinder(FileOperations fileOperations) {
    this.fileOperations = fileOperations;
}
 
Example 19
public ClassSetAnalysisUpdater(Stash<ClassSetAnalysisData> stash, FileOperations fileOperations, ClassDependenciesAnalyzer analyzer) {
    this.stash = stash;
    this.fileOperations = fileOperations;
    this.analyzer = analyzer;
}
 
Example 20
public RecompilationSpecProvider(SourceToNameConverter sourceToNameConverter, FileOperations fileOperations) {
    this.sourceToNameConverter = sourceToNameConverter;
    this.fileOperations = fileOperations;
}
 
Example 21
public IncrementalCompilationInitializer(FileOperations fileOperations) {
    this.fileOperations = fileOperations;
}
 
Example 22
@Inject
protected FileOperations getFileOperations() {
    // Decoration takes care of the implementation
    throw new UnsupportedOperationException();
}
 
Example 23
public DefaultResourceHandler(FileOperations fileOperations, TemporaryFileProvider tempFileProvider) {
    this.fileOperations = fileOperations;
    textResourceFactory = new DefaultTextResourceFactory(fileOperations, tempFileProvider);
}
 
Example 24
public DefaultTextResourceFactory(FileOperations fileOperations, TemporaryFileProvider tempFileProvider) {
    this.fileOperations = fileOperations;
    this.tempFileProvider = tempFileProvider;
}
 
Example 25
public DefaultDistributionContainer(Class<Distribution> type, Instantiator instantiator, FileOperations fileOperations) {
    super(type, instantiator);
    this.fileOperations = fileOperations;
}
 
Example 26
public DefaultDistributionContainer(Class<Distribution> type, Instantiator instantiator, FileOperations fileOperations) {
    super(type, instantiator);
    this.fileOperations = fileOperations;
}
 
Example 27
public void execute(final FileCollection source, File destDir, boolean use, String windowTitle, String docTitle, String header, String footer, String overview, boolean includePrivate, final Set<Groovydoc.Link> links, final Iterable<File> groovyClasspath, Iterable<File> classpath, Project project) {

        final File tmpDir = new File(project.getBuildDir(), "tmp/groovydoc");
        FileOperations fileOperations = (ProjectInternal) project;
        fileOperations.delete(tmpDir);
        fileOperations.copy(new Action<CopySpec>() {
            public void execute(CopySpec copySpec) {
                copySpec.from(source).into(tmpDir);
            }
        });

        final Map<String, Object> args = Maps.newLinkedHashMap();
        args.put("sourcepath", tmpDir.toString());
        args.put("destdir", destDir);
        args.put("use", use);
        args.put("private", includePrivate);
        putIfNotNull(args, "windowtitle", windowTitle);
        putIfNotNull(args, "doctitle", docTitle);
        putIfNotNull(args, "header", header);
        putIfNotNull(args, "footer", footer);
        putIfNotNull(args, "overview", overview);

        List<File> combinedClasspath = ImmutableList.<File>builder()
                .addAll(classpath)
                .addAll(groovyClasspath)
                .build();

        ant.withClasspath(combinedClasspath).execute(new Closure<Object>(this, this) {
            @SuppressWarnings("UnusedDeclaration")
            public Object doCall(Object it) {
                final GroovyObjectSupport antBuilder = (GroovyObjectSupport) it;

                antBuilder.invokeMethod("taskdef", ImmutableMap.of(
                        "name", "groovydoc",
                        "classname", "org.codehaus.groovy.ant.Groovydoc"
                ));

                antBuilder.invokeMethod("groovydoc", new Object[]{args, new Closure<Object>(this, this) {
                    public Object doCall(Object ignore) {
                        for (Groovydoc.Link link : links) {
                            antBuilder.invokeMethod("link", new Object[]{
                                    ImmutableMap.of(
                                            "packages", Joiner.on(",").join(link.getPackages()),
                                            "href", link.getUrl()
                                    )
                            });
                        }

                        return null;
                    }
                }});

                return null;
            }
        });
    }
 
Example 28
public JarChangeProcessor(FileOperations fileOperations, JarClasspathSnapshot jarClasspathSnapshot, PreviousCompilation previousCompilation) {
    this.fileOperations = fileOperations;
    this.jarClasspathSnapshot = jarClasspathSnapshot;
    this.previousCompilation = previousCompilation;
}
 
Example 29
public ClasspathJarFinder(FileOperations fileOperations) {
    this.fileOperations = fileOperations;
}
 
Example 30
public ClassSetAnalysisUpdater(Stash<ClassSetAnalysisData> stash, FileOperations fileOperations, ClassDependenciesAnalyzer analyzer) {
    this.stash = stash;
    this.fileOperations = fileOperations;
    this.analyzer = analyzer;
}