Java 类org.gradle.api.file.FileTree 实例源码

项目:Reer    文件:DefaultScalaJavaJointCompiler.java   
public WorkResult execute(ScalaJavaJointCompileSpec spec) {
    scalaCompiler.execute(spec);

    PatternFilterable patternSet = new PatternSet();
    patternSet.include("**/*.java");
    FileTree javaSource = spec.getSource().getAsFileTree().matching(patternSet);
    if (!javaSource.isEmpty()) {
        spec.setSource(javaSource);
        javaCompiler.execute(spec);
    }

    return new WorkResult() {
        public boolean getDidWork() {
            return true;
        }
    };
}
项目:Reer    文件:DefaultJarSnapshotter.java   
JarSnapshot createSnapshot(HashCode hash, FileTree classes, final ClassFilesAnalyzer analyzer) {
    final Map<String, HashCode> hashes = Maps.newHashMap();
    classes.visit(new FileVisitor() {
        public void visitDir(FileVisitDetails dirDetails) {
        }

        public void visitFile(FileVisitDetails fileDetails) {
            analyzer.visitFile(fileDetails);
            String className = fileDetails.getPath().replaceAll("/", ".").replaceAll("\\.class$", "");
            HashCode classHash = hasher.hash(fileDetails.getFile());
            hashes.put(className, classHash);
        }
    });

    return new JarSnapshot(new JarSnapshotData(hash, hashes, analyzer.getAnalysis()));
}
项目:Reer    文件:IncrementalCompilationInitializer.java   
public void initializeCompilation(JavaCompileSpec spec, Collection<String> staleClasses) {
    if (staleClasses.isEmpty()) {
        spec.setSource(new SimpleFileCollection());
        return; //do nothing. No classes need recompilation.
    }

    Factory<PatternSet> patternSetFactory = fileOperations.getFileResolver().getPatternSetFactory();
    PatternSet classesToDelete = patternSetFactory.create();
    PatternSet sourceToCompile = patternSetFactory.create();

    preparePatterns(staleClasses, classesToDelete, sourceToCompile);

    //selectively configure the source
    spec.setSource(spec.getSource().getAsFileTree().matching(sourceToCompile));
    //since we're compiling selectively we need to include the classes compiled previously
    spec.setClasspath(Iterables.concat(spec.getClasspath(), asList(spec.getDestinationDir())));
    //get rid of stale files
    FileTree deleteMe = fileOperations.fileTree(spec.getDestinationDir()).matching(classesToDelete);
    fileOperations.delete(deleteMe);
}
项目:Reer    文件:WindowsResourcesCompileTaskConfig.java   
private void configureResourceCompileTask(WindowsResourceCompile task, final NativeBinarySpecInternal binary, final WindowsResourceSet sourceSet) {
    task.setDescription("Compiles resources of the " + sourceSet + " of " + binary);

    task.setToolChain(binary.getToolChain());
    task.setTargetPlatform(binary.getTargetPlatform());

    task.includes(sourceSet.getExportedHeaders().getSourceDirectories());
    task.source(sourceSet.getSource());

    final Project project = task.getProject();
    task.setOutputDir(new File(binary.getNamingScheme().getOutputDirectory(project.getBuildDir(), "objs"), ((LanguageSourceSetInternal) sourceSet).getProjectScopedName()));

    PreprocessingTool rcCompiler = (PreprocessingTool) binary.getToolByName("rcCompiler");
    task.setMacros(rcCompiler.getMacros());
    task.setCompilerArgs(rcCompiler.getArgs());

    FileTree resourceOutputs = task.getOutputs().getFiles().getAsFileTree().matching(new PatternSet().include("**/*.res"));
    binary.binaryInputs(resourceOutputs);
    if (binary instanceof StaticLibraryBinarySpecInternal) {
        ((StaticLibraryBinarySpecInternal) binary).additionalLinkFiles(resourceOutputs);
    }
}
项目:Reer    文件:AbstractFileCollection.java   
public Object asType(Class<?> type) throws UnsupportedOperationException {
    if (type.isAssignableFrom(Set.class)) {
        return getFiles();
    }
    if (type.isAssignableFrom(List.class)) {
        return new ArrayList<File>(getFiles());
    }
    if (type.isAssignableFrom(File[].class)) {
        Set<File> files = getFiles();
        return files.toArray(new File[0]);
    }
    if (type.isAssignableFrom(File.class)) {
        return getSingleFile();
    }
    if (type.isAssignableFrom(FileCollection.class)) {
        return this;
    }
    if (type.isAssignableFrom(FileTree.class)) {
        return getAsFileTree();
    }
    throw new UnsupportedOperationException(String.format("Cannot convert %s to type %s, as this type is not supported.", getDisplayName(), type.getSimpleName()));
}
项目:ide-plugins    文件:EclipseTestExecuter.java   
private List<String> collectTestNames(Test testTask, Object testTaskOperationId, Object rootTestSuiteId) {
    ClassNameCollectingProcessor processor = new ClassNameCollectingProcessor();
    Runnable detector;
    final FileTree testClassFiles = testTask.getCandidateClassFiles();
    if (testTask.isScanForTestClasses()) {
        TestFrameworkDetector testFrameworkDetector = testTask.getTestFramework().getDetector();
        testFrameworkDetector.setTestClasses(testTask.getTestClassesDirs().getFiles());
        testFrameworkDetector.setTestClasspath(testTask.getClasspath().getFiles());
        detector = new EclipsePluginTestClassScanner(testClassFiles, processor);
    } else {
        detector = new EclipsePluginTestClassScanner(testClassFiles, processor);
    }

    new TestMainAction(detector, processor, new NoOpTestResultProcessor(), Time.clock(), testTaskOperationId, rootTestSuiteId, String.format("Gradle Eclipse Test Run %s", testTask.getIdentityPath())).run();
    LOGGER.info("collected test class names: {}", processor.classNames);
    return processor.classNames;
}
项目:intellij-ce-playground    文件:TaskManager.java   
public Copy getJacocoAgentTask() {
    if (jacocoAgentTask == null) {
        jacocoAgentTask = project.getTasks().create("unzipJacocoAgent", Copy.class);
        jacocoAgentTask.from(new Callable<List<FileTree>>() {
            @Override
            public List<FileTree> call() throws Exception {
                return Lists.newArrayList(Iterables.transform(
                        project.getConfigurations().getByName(
                                JacocoPlugin.AGENT_CONFIGURATION_NAME),
                        new Function<Object, FileTree>() {
                            @Override
                            public FileTree apply(@Nullable Object it) {
                                return project.zipTree(it);
                            }
                        }));
            }
        });
        jacocoAgentTask.include(FILE_JACOCO_AGENT);
        jacocoAgentTask.into(new File(getGlobalScope().getIntermediatesDir(), "jacoco"));
    }

    return jacocoAgentTask;
}
项目:Pushjet-Android    文件:DefaultScalaJavaJointCompiler.java   
public WorkResult execute(ScalaJavaJointCompileSpec spec) {
    scalaCompiler.execute(spec);

    PatternFilterable patternSet = new PatternSet();
    patternSet.include("**/*.java");
    FileTree javaSource = spec.getSource().getAsFileTree().matching(patternSet);
    if (!javaSource.isEmpty()) {
        spec.setSource(javaSource);
        javaCompiler.execute(spec);
    }

    return new WorkResult() {
        public boolean getDidWork() {
            return true;
        }
    };
}
项目:Pushjet-Android    文件:WindowsResourcesCompileTaskConfig.java   
private void configureResourceCompileTask(WindowsResourceCompile task, final NativeBinarySpecInternal binary, final WindowsResourceSet sourceSet) {
    task.setDescription(String.format("Compiles resources of the %s of %s", sourceSet, binary));

    task.setToolChain(binary.getToolChain());
    task.setTargetPlatform(binary.getTargetPlatform());

    task.includes(new Callable<Set<File>>() {
        public Set<File> call() {
            return sourceSet.getExportedHeaders().getSrcDirs();
        }
    });
    task.source(sourceSet.getSource());

    final Project project = task.getProject();
    task.setOutputDir(project.file(String.valueOf(project.getBuildDir()) + "/objs/" + binary.getNamingScheme().getOutputDirectoryBase() + "/" + ((LanguageSourceSetInternal) sourceSet).getFullName()));

    PreprocessingTool rcCompiler = (PreprocessingTool) ((ExtensionAware) binary).getExtensions().getByName("rcCompiler");
    task.setMacros(rcCompiler.getMacros());
    task.setCompilerArgs(rcCompiler.getArgs());

    FileTree resourceOutputs = task.getOutputs().getFiles().getAsFileTree().matching(new PatternSet().include("**/*.res"));
    binary.getTasks().getCreateOrLink().source(resourceOutputs);
    if (binary instanceof StaticLibraryBinarySpecInternal) {
        ((StaticLibraryBinarySpecInternal) binary).additionalLinkFiles(resourceOutputs);
    }
}
项目:Pushjet-Android    文件:FileCollectionBackedArchiveTextResource.java   
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);
}
项目:Pushjet-Android    文件:CompositeFileCollection.java   
@Override
public FileTree getAsFileTree() {
    return new CompositeFileTree() {
        @Override
        public void resolve(FileCollectionResolveContext context) {
            ResolvableFileCollectionResolveContext nested = context.newContext();
            CompositeFileCollection.this.resolve(nested);
            context.add(nested.resolveAsFileTrees());
        }

        @Override
        public String getDisplayName() {
            return CompositeFileCollection.this.getDisplayName();
        }
    };
}
项目:Pushjet-Android    文件:AbstractFileCollection.java   
public Object asType(Class<?> type) throws UnsupportedOperationException {
    if (type.isAssignableFrom(Set.class)) {
        return getFiles();
    }
    if (type.isAssignableFrom(List.class)) {
        return new ArrayList<File>(getFiles());
    }
    if (type.isAssignableFrom(File[].class)) {
        Set<File> files = getFiles();
        return files.toArray(new File[files.size()]);
    }
    if (type.isAssignableFrom(File.class)) {
        return getSingleFile();
    }
    if (type.isAssignableFrom(FileCollection.class)) {
        return this;
    }
    if (type.isAssignableFrom(FileTree.class)) {
        return getAsFileTree();
    }
    throw new UnsupportedOperationException(String.format("Cannot convert %s to type %s, as this type is not supported.", getDisplayName(), type.getSimpleName()));
}
项目:Pushjet-Android    文件:DefaultScalaJavaJointCompiler.java   
public WorkResult execute(ScalaJavaJointCompileSpec spec) {
    scalaCompiler.execute(spec);

    PatternFilterable patternSet = new PatternSet();
    patternSet.include("**/*.java");
    FileTree javaSource = spec.getSource().getAsFileTree().matching(patternSet);
    if (!javaSource.isEmpty()) {
        spec.setSource(javaSource);
        javaCompiler.execute(spec);
    }

    return new WorkResult() {
        public boolean getDidWork() {
            return true;
        }
    };
}
项目:Pushjet-Android    文件:SourceTask.java   
/**
 * Returns the source for this task, after the include and exclude patterns have been applied. Ignores source files which do not exist.
 *
 * @return The source.
 */
@InputFiles
@SkipWhenEmpty
public FileTree getSource() {
    FileTree src;
    if (this.source.isEmpty()) {
        src = DeprecationLogger.whileDisabled(new Factory<FileTree>() {
            public FileTree create() {
                return getDefaultSource();
            }
        });
    } else {
        src = getProject().files(new ArrayList<Object>(this.source)).getAsFileTree();
    }
    return src == null ? getProject().files().getAsFileTree() : src.matching(patternSet);
}
项目:Pushjet-Android    文件:AbstractFileCollection.java   
public Object asType(Class<?> type) throws UnsupportedOperationException {
    if (type.isAssignableFrom(Set.class)) {
        return getFiles();
    }
    if (type.isAssignableFrom(List.class)) {
        return new ArrayList<File>(getFiles());
    }
    if (type.isAssignableFrom(File[].class)) {
        Set<File> files = getFiles();
        return files.toArray(new File[files.size()]);
    }
    if (type.isAssignableFrom(File.class)) {
        return getSingleFile();
    }
    if (type.isAssignableFrom(FileCollection.class)) {
        return this;
    }
    if (type.isAssignableFrom(FileTree.class)) {
        return getAsFileTree();
    }
    throw new UnsupportedOperationException(String.format("Cannot convert %s to type %s, as this type is not supported.", getDisplayName(), type.getSimpleName()));
}
项目:Pushjet-Android    文件:CompositeFileCollection.java   
@Override
public FileTree getAsFileTree() {
    return new CompositeFileTree() {
        @Override
        public void resolve(FileCollectionResolveContext context) {
            ResolvableFileCollectionResolveContext nested = context.newContext();
            CompositeFileCollection.this.resolve(nested);
            context.add(nested.resolveAsFileTrees());
        }

        @Override
        public String getDisplayName() {
            return CompositeFileCollection.this.getDisplayName();
        }
    };
}
项目:Reer    文件:AntlrTask.java   
/**
 * Returns the source for this task, after the include and exclude patterns have been applied. Ignores source files which do not exist.
 *
 * @return The source.
 */
// This method is here as the Gradle DSL generation can't handle properties with setters and getters in different classes.
@InputFiles
@SkipWhenEmpty
public FileTree getSource() {
    return super.getSource();
}
项目:Reer    文件:SerializableCoffeeScriptCompileSpec.java   
public static void toRelativeFiles(final FileCollection source, final List<RelativeFile> targets) {
    FileTree fileTree = source.getAsFileTree();

    fileTree.visit(new FileVisitor() {
        public void visitDir(FileVisitDetails dirDetails) {}

        public void visitFile(FileVisitDetails fileDetails) {
            targets.add(new RelativeFile(fileDetails.getFile(), fileDetails.getRelativePath()));
        }
    });
}
项目:Reer    文件:ClassSetAnalysisUpdater.java   
public void updateAnalysis(JavaCompileSpec spec) {
    Timer clock = Timers.startTimer();
    FileTree tree = fileOperations.fileTree(spec.getDestinationDir());
    ClassFilesAnalyzer analyzer = new ClassFilesAnalyzer(this.analyzer);
    tree.visit(analyzer);
    ClassSetAnalysisData data = analyzer.getAnalysis();
    stash.put(data);
    LOG.info("Class dependency analysis for incremental compilation took {}.", clock.getElapsed());
}
项目:Reer    文件:DefaultTestExecuter.java   
@Override
public void execute(final Test testTask, TestResultProcessor testResultProcessor) {
    final TestFramework testFramework = testTask.getTestFramework();
    final WorkerTestClassProcessorFactory testInstanceFactory = testFramework.getProcessorFactory();
    final BuildOperationWorkerRegistry.Operation currentOperation = buildOperationWorkerRegistry.getCurrent();
    final Set<File> classpath = ImmutableSet.copyOf(testTask.getClasspath());
    final Factory<TestClassProcessor> forkingProcessorFactory = new Factory<TestClassProcessor>() {
        public TestClassProcessor create() {
            return new ForkingTestClassProcessor(workerFactory, testInstanceFactory, testTask,
                classpath, testFramework.getWorkerConfigurationAction(), moduleRegistry, currentOperation);
        }
    };
    Factory<TestClassProcessor> reforkingProcessorFactory = new Factory<TestClassProcessor>() {
        public TestClassProcessor create() {
            return new RestartEveryNTestClassProcessor(forkingProcessorFactory, testTask.getForkEvery());
        }
    };

    TestClassProcessor processor = new MaxNParallelTestClassProcessor(testTask.getMaxParallelForks(),
        reforkingProcessorFactory, actorFactory);

    final FileTree testClassFiles = testTask.getCandidateClassFiles();

    Runnable detector;
    if (testTask.isScanForTestClasses()) {
        TestFrameworkDetector testFrameworkDetector = testTask.getTestFramework().getDetector();
        testFrameworkDetector.setTestClassesDirectory(testTask.getTestClassesDir());
        testFrameworkDetector.setTestClasspath(classpath);
        detector = new DefaultTestClassScanner(testClassFiles, testFrameworkDetector, processor);
    } else {
        detector = new DefaultTestClassScanner(testClassFiles, null, processor);
    }

    final Object testTaskOperationId = buildOperationExecutor.getCurrentOperation().getId();

    new TestMainAction(detector, processor, testResultProcessor, new TrueTimeProvider(), testTaskOperationId, testTask.getPath(), "Gradle Test Run " + testTask.getIdentityPath()).run();
}
项目:Reer    文件:SourceTask.java   
/**
 * Returns the source for this task, after the include and exclude patterns have been applied. Ignores source files which do not exist.
 *
 * @return The source.
 */
@InputFiles
@SkipWhenEmpty
public FileTree getSource() {
    ArrayList<Object> copy = new ArrayList<Object>(this.source);
    FileTree src = getProject().files(copy).getAsFileTree();
    return src == null ? getProject().files().getAsFileTree() : src.matching(patternSet);
}
项目:Reer    文件:FileCollectionBackedArchiveTextResource.java   
public FileCollectionBackedArchiveTextResource(final FileOperations fileOperations,
                                               final TemporaryFileProvider tempFileProvider,
                                               final FileCollection fileCollection,
                                               final String path, Charset charset) {
    super(tempFileProvider, new LazilyInitializedFileCollection() {
        @Override
        public String getDisplayName() {
            return String.format("entry '%s' in archive %s", path, fileCollection);
        }

        @Override
        public FileCollection 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);
        }

        @Override
        public void visitDependencies(TaskDependencyResolveContext context) {
            context.add(fileCollection);
        }
    }, charset);
}
项目:Reer    文件:CompositeFileTree.java   
@Override
public FileTree visit(Action<? super FileVisitDetails> visitor) {
    for (FileTree tree : getSourceCollections()) {
        tree.visit(visitor);
    }
    return this;
}
项目:Reer    文件:CompositeFileTree.java   
@Override
public void visitContents(FileCollectionResolveContext context) {
    ResolvableFileCollectionResolveContext nestedContext = context.newContext();
    CompositeFileTree.this.visitContents(nestedContext);
    for (FileTree set : nestedContext.resolveAsFileTrees()) {
        if (action != null) {
            context.add(set.matching(action));
        } else {
            context.add(set.matching(patterns));
        }
    }
}
项目:Reer    文件:UnionFileTree.java   
@Override
public UnionFileTree add(FileCollection source) {
    if (!(source instanceof FileTree)) {
        throw new UnsupportedOperationException(String.format("Can only add FileTree instances to %s.", getDisplayName()));
    }

    sourceTrees.add(Cast.cast(FileTreeInternal.class, source));
    return this;
}
项目:Reer    文件:FileTreeAdapter.java   
@Override
public FileTree matching(PatternFilterable patterns) {
    if (tree instanceof PatternFilterableFileTree) {
        PatternFilterableFileTree filterableTree = (PatternFilterableFileTree) tree;
        return new FileTreeAdapter(filterableTree.filter(patterns));
    }
    return super.matching(patterns);
}
项目:Reer    文件:DefaultCopySpec.java   
public FileTree getAllSource() {
    final ImmutableList.Builder<FileTree> builder = ImmutableList.builder();
    walk(new Action<CopySpecResolver>() {
        public void execute(CopySpecResolver copySpecResolver) {
            builder.add(copySpecResolver.getSource());
        }
    });

    return fileResolver.compositeFileTree(builder.build());
}
项目:gradle-plugins    文件:ExplodedArchivesPlugin.java   
@Override
public void apply(final Project project) {

    explodedArchives = project.getExtensions().create("explodedArchives", ExplodedArchivesExtension.class);

    explodeAll = project.getTasks().create("explode");
    explodeAll.setGroup(BasePlugin.BUILD_GROUP);

    project.getTasks().withType(AbstractArchiveTask.class, archiveTask -> {
        Sync explodeArchive = project.getTasks().create("explode" + capitalize((CharSequence) archiveTask.getName()), Sync.class);

        explodeAll.dependsOn(explodeArchive);
        explodeArchive.dependsOn(archiveTask);

        explodeArchive.getConventionMapping()
                .map("group", (Callable<String>) archiveTask::getGroup);

        explodeArchive.getConventionMapping()
                .map("destinationDir", (Callable<File>) () -> {
                    File explodedDir = new File(archiveTask.getDestinationDir(), "exploded");
                    if (explodedArchives.isIncludeExtension()) {
                        return new File(explodedDir, archiveTask.getArchiveName());
                    } else {
                        return new File(explodedDir, minus((CharSequence) archiveTask.getArchiveName(), "." + archiveTask.getExtension()));
                    }
                });

        explodeArchive.from((Callable<FileTree>) () -> project.zipTree(archiveTask.getArchivePath()));
    });
}
项目:gradle-postman-runner    文件:PreferredSettings.java   
@Override
public FileTree getCollections() {
    if (collections == null) {
        return getNewmanSettings().getCollections();
    }
    return collections;
}
项目:intellij-ce-playground    文件:PackageApplication.java   
@InputFiles
public FileTree getNativeLibraries() {
    FileTree src = null;
    Set<File> folders = getJniFolders();
    if (!folders.isEmpty()) {
        src = getProject().files(new ArrayList<Object>(folders)).getAsFileTree();
    }

    return src == null ? getProject().files().getAsFileTree() : src;
}
项目:intellij-ce-playground    文件:DefaultAndroidSourceDirectorySet.java   
@Override
@NonNull
public FileTree getSourceFiles() {
    FileTree src = null;
    Set<File> sources = getSrcDirs();
    if (!sources.isEmpty()) {
        src = project.files(new ArrayList<Object>(sources)).getAsFileTree().matching(filter);
    }
    return src == null ? project.files().getAsFileTree() : src;
}
项目:Pushjet-Android    文件:JarSnapshotter.java   
JarSnapshot createSnapshot(FileTree archivedClasses) {
    final Map<String, byte[]> hashes = new HashMap<String, byte[]>();
    archivedClasses.visit(new FileVisitor() {
        public void visitDir(FileVisitDetails dirDetails) {
        }

        public void visitFile(FileVisitDetails fileDetails) {
            hashes.put(fileDetails.getPath().replaceAll("/", ".").replaceAll("\\.class$", ""), hasher.hash(fileDetails.getFile()));
        }
    });
    return new JarSnapshot(hashes);
}
项目:Pushjet-Android    文件:ClassSetAnalysisUpdater.java   
public void updateAnalysis(JavaCompileSpec spec) {
    Clock clock = new Clock();
    FileTree tree = fileOperations.fileTree(spec.getDestinationDir());
    ClassFilesAnalyzer analyzer = new ClassFilesAnalyzer(this.analyzer);
    tree.visit(analyzer);
    ClassSetAnalysisData data = analyzer.getAnalysis();
    stash.put(data);
    LOG.info("Class dependency analysis for incremental compilation took {}.", clock.getTime());
}
项目:Pushjet-Android    文件:DefaultTestExecuter.java   
public void execute(final Test testTask, TestResultProcessor testResultProcessor) {
    final TestFramework testFramework = testTask.getTestFramework();
    final WorkerTestClassProcessorFactory testInstanceFactory = testFramework.getProcessorFactory();
    final Factory<TestClassProcessor> forkingProcessorFactory = new Factory<TestClassProcessor>() {
        public TestClassProcessor create() {
            return new ForkingTestClassProcessor(workerFactory, testInstanceFactory, testTask,
                    testTask.getClasspath(), testFramework.getWorkerConfigurationAction());
        }
    };
    Factory<TestClassProcessor> reforkingProcessorFactory = new Factory<TestClassProcessor>() {
        public TestClassProcessor create() {
            return new RestartEveryNTestClassProcessor(forkingProcessorFactory, testTask.getForkEvery());
        }
    };

    TestClassProcessor processor = new MaxNParallelTestClassProcessor(testTask.getMaxParallelForks(),
            reforkingProcessorFactory, actorFactor);

    final FileTree testClassFiles = testTask.getCandidateClassFiles();

    Runnable detector;
    if (testTask.isScanForTestClasses()) {
        TestFrameworkDetector testFrameworkDetector = testTask.getTestFramework().getDetector();
        testFrameworkDetector.setTestClassesDirectory(testTask.getTestClassesDir());
        testFrameworkDetector.setTestClasspath(testTask.getClasspath());
        detector = new DefaultTestClassScanner(testClassFiles, testFrameworkDetector, processor);
    } else {
        detector = new DefaultTestClassScanner(testClassFiles, null, processor);
    }
    new TestMainAction(detector, processor, testResultProcessor, new TrueTimeProvider()).run();
}
项目:Pushjet-Android    文件:SourceTask.java   
/**
 * Returns the source for this task, after the include and exclude patterns have been applied. Ignores source files which do not exist.
 *
 * @return The source.
 */
@InputFiles
@SkipWhenEmpty
public FileTree getSource() {
    FileTree src = getProject().files(new ArrayList<Object>(this.source)).getAsFileTree();
    return src == null ? getProject().files().getAsFileTree() : src.matching(patternSet);
}
项目:Pushjet-Android    文件:SelectiveCompilation.java   
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());
}
项目:Pushjet-Android    文件:BuildDependenciesOnlyFileCollectionResolveContext.java   
public void convertInto(Object element, Collection<? super FileTree> result, FileResolver resolver) {
    if (element instanceof DefaultFileCollectionResolveContext) {
        DefaultFileCollectionResolveContext nestedContext = (DefaultFileCollectionResolveContext) element;
        result.addAll(nestedContext.resolveAsFileTrees());
    } else if (element instanceof Buildable) {
        Buildable buildable = (Buildable) element;
        result.add(new FileTreeAdapter(new EmptyFileTree(buildable.getBuildDependencies())));
    } else if (element instanceof TaskDependency) {
        TaskDependency dependency = (TaskDependency) element;
        result.add(new FileTreeAdapter(new EmptyFileTree(dependency)));
    }
}
项目:Pushjet-Android    文件:UnionFileTree.java   
@Override
public UnionFileTree add(FileCollection source) {
    if (!(source instanceof FileTree)) {
        throw new UnsupportedOperationException(String.format("Can only add FileTree instances to %s.", getDisplayName()));
    }

    sourceTrees.add((FileTree) source);
    return this;
}
项目:Pushjet-Android    文件:FileTreeAdapter.java   
@Override
public FileTree matching(PatternFilterable patterns) {
    if (tree instanceof PatternFilterableFileTree) {
        PatternFilterableFileTree filterableTree = (PatternFilterableFileTree) tree;
        return new FileTreeAdapter(filterableTree.filter(patterns));
    }
    return super.matching(patterns);
}
项目:Pushjet-Android    文件:LazilyInitializedFileTree.java   
@Override
public final synchronized FileTree getDelegate() {
    if (delegate == null) {
        delegate = createDelegate();
    }
    return delegate;
}