Java 类org.gradle.api.internal.file.collections.SimpleFileCollection 实例源码

项目:Reer    文件:NormalizingGroovyCompiler.java   
private void resolveAndFilterSourceFiles(final GroovyJavaJointCompileSpec spec) {
    final List<String> fileExtensions = CollectionUtils.collect(spec.getGroovyCompileOptions().getFileExtensions(), new Transformer<String, String>() {
        @Override
        public String transform(String extension) {
            return '.' + extension;
        }
    });
    FileCollection filtered = spec.getSource().filter(new Spec<File>() {
        public boolean isSatisfiedBy(File element) {
            for (String fileExtension : fileExtensions) {
                if (hasExtension(element, fileExtension)) {
                    return true;
                }
            }
            return false;
        }
    });

    spec.setSource(new SimpleFileCollection(filtered.getFiles()));
}
项目: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);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:BootRunTask.java   
private void addResourcesIfNecessary() {
    if (this.addResources) {
        SourceSet mainSourceSet = SourceSets.findMainSourceSet(getProject());
        final File outputDir = (mainSourceSet == null ? null
                : mainSourceSet.getOutput().getResourcesDir());
        final Set<File> resources = new LinkedHashSet<File>();
        if (mainSourceSet != null) {
            resources.addAll(mainSourceSet.getResources().getSrcDirs());
        }
        List<File> classPath = new ArrayList<File>(getClasspath().getFiles());
        classPath.addAll(0, resources);
        getLogger().info("Adding classpath: " + resources);
        setClasspath(new SimpleFileCollection(classPath));
        if (outputDir != null) {
            for (File directory : resources) {
                FileUtils.removeDuplicatesFromOutputDirectory(outputDir, directory);
            }
        }
    }
}
项目:spring-boot-concourse    文件:BootRunTask.java   
private void addResourcesIfNecessary() {
    if (this.addResources) {
        SourceSet mainSourceSet = SourceSets.findMainSourceSet(getProject());
        final File outputDir = (mainSourceSet == null ? null
                : mainSourceSet.getOutput().getResourcesDir());
        final Set<File> resources = new LinkedHashSet<File>();
        if (mainSourceSet != null) {
            resources.addAll(mainSourceSet.getResources().getSrcDirs());
        }
        List<File> classPath = new ArrayList<File>(getClasspath().getFiles());
        classPath.addAll(0, resources);
        getLogger().info("Adding classpath: " + resources);
        setClasspath(new SimpleFileCollection(classPath));
        if (outputDir != null) {
            for (File directory : resources) {
                FileUtils.removeDuplicatesFromOutputDirectory(outputDir, directory);
            }
        }
    }
}
项目:contestparser    文件:BootRunTask.java   
private void addResourcesIfNecessary() {
    if (this.addResources) {
        SourceSet mainSourceSet = SourceSets.findMainSourceSet(getProject());
        final File outputDir = (mainSourceSet == null ? null
                : mainSourceSet.getOutput().getResourcesDir());
        final Set<File> resources = new LinkedHashSet<File>();
        if (mainSourceSet != null) {
            resources.addAll(mainSourceSet.getResources().getSrcDirs());
        }
        List<File> classPath = new ArrayList<File>(getClasspath().getFiles());
        classPath.addAll(0, resources);
        getLogger().info("Adding classpath: " + resources);
        setClasspath(new SimpleFileCollection(classPath));
        if (outputDir != null) {
            for (File directory : resources) {
                FileUtils.removeDuplicatesFromOutputDirectory(outputDir, directory);
            }
        }
    }
}
项目:goomph    文件:JavaExecableImp.java   
static FileCollection fromLocalClassloader() {
    Set<File> files = new LinkedHashSet<>();
    Consumer<Class<?>> addPeerClasses = clazz -> {
        URLClassLoader urlClassloader = (URLClassLoader) clazz.getClassLoader();
        for (URL url : urlClassloader.getURLs()) {
            String name = url.getFile();
            if (name != null) {
                files.add(new File(name));
            }
        }
    };
    // add the classes that goomph needs
    addPeerClasses.accept(JavaExecable.class);
    // add the gradle API
    addPeerClasses.accept(JavaExec.class);

    return new SimpleFileCollection(files);
}
项目:Pushjet-Android    文件:IncrementalCompilationInitializer.java   
public void initializeCompilation(JavaCompileSpec spec, Collection<String> staleClasses) {
    if (staleClasses.isEmpty()) {
        spec.setSource(new SimpleFileCollection());
        return; //do nothing. No classes need recompilation.
    }

    PatternSet classesToDelete = new PatternSet();
    PatternSet sourceToCompile = new PatternSet();

    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    文件:JavaInstallationProbe.java   
private EnumMap<SysProp, String> getMetadataInternal(File jdkPath) {
    JavaExecAction exec = factory.newJavaExecAction();
    exec.executable(javaExe(jdkPath, "java"));
    File workingDir = Files.createTempDir();
    exec.setWorkingDir(workingDir);
    exec.setClasspath(new SimpleFileCollection(workingDir));
    try {
        writeProbe(workingDir);
        exec.setMain(JavaProbe.CLASSNAME);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        exec.setStandardOutput(baos);
        ByteArrayOutputStream errorOutput = new ByteArrayOutputStream();
        exec.setErrorOutput(errorOutput);
        exec.setIgnoreExitValue(true);
        ExecResult result = exec.execute();
        int exitValue = result.getExitValue();
        if (exitValue == 0) {
            return parseExecOutput(baos.toString());
        }
        return error("Command returned unexpected result code: " + exitValue + "\nError output:\n" + errorOutput);
    } catch (ExecException ex) {
        return error(ex.getMessage());
    } finally {
        try {
            FileUtils.deleteDirectory(workingDir);
        } catch (IOException e) {
            throw new GradleException("Unable to delete temp directory", e);
        }
    }
}
项目:Reer    文件:NormalizingJavaCompiler.java   
private void resolveAndFilterSourceFiles(JavaCompileSpec spec) {
    // this mimics the behavior of the Ant javac task (and therefore AntJavaCompiler),
    // which silently excludes files not ending in .java
    FileCollection javaOnly = spec.getSource().filter(new Spec<File>() {
        public boolean isSatisfiedBy(File element) {
            return hasExtension(element, ".java");
        }
    });

    spec.setSource(new SimpleFileCollection(javaOnly.getFiles()));
}
项目:Reer    文件:PlayPluginConfigurations.java   
@Override
public FileCollectionInternal createDelegate() {
    ImmutableSet.Builder<File> files = ImmutableSet.builder();
    for (ResolvedArtifact artifact : configuration.getResolvedConfiguration().getResolvedArtifacts()) {
        if ((artifact.getId().getComponentIdentifier() instanceof ProjectComponentIdentifier) == matchProjectComponents) {
            files.add(artifact.getFile());
        }
    }
    return new SimpleFileCollection(files.build());
}
项目:Pushjet-Android    文件:NormalizingGroovyCompiler.java   
private void resolveAndFilterSourceFiles(final GroovyJavaJointCompileSpec spec) {
    FileCollection filtered = spec.getSource().filter(new Spec<File>() {
        public boolean isSatisfiedBy(File element) {
            for (String fileExtension : spec.getGroovyCompileOptions().getFileExtensions()) {
                if (element.getName().endsWith("." + fileExtension)) {
                    return true;
                }
            }
            return false;
        }
    });

    spec.setSource(new SimpleFileCollection(filtered.getFiles()));
}
项目:Pushjet-Android    文件:NormalizingJavaCompiler.java   
private void resolveAndFilterSourceFiles(JavaCompileSpec spec) {
    // this mimics the behavior of the Ant javac task (and therefore AntJavaCompiler),
    // which silently excludes files not ending in .java
    FileCollection javaOnly = spec.getSource().filter(new Spec<File>() {
        public boolean isSatisfiedBy(File element) {
            return element.getName().endsWith(".java");
        }
    });

    spec.setSource(new SimpleFileCollection(javaOnly.getFiles()));
}
项目:Pushjet-Android    文件:DefaultFileCollectionSnapshotter.java   
public FileCollection getFiles() {
    List<File> files = new ArrayList<File>();
    for (Map.Entry<String, IncrementalFileSnapshot> entry : snapshots.entrySet()) {
        if (entry.getValue() instanceof FileHashSnapshot) {
            files.add(new File(entry.getKey()));
        }
    }
    return new SimpleFileCollection(files);
}
项目:Pushjet-Android    文件:NormalizingScalaCompiler.java   
private void resolveClasspath(ScalaJavaJointCompileSpec spec) {
    spec.setClasspath(new SimpleFileCollection(Lists.newArrayList(spec.getClasspath())));
    spec.setScalaClasspath(new SimpleFileCollection(Lists.newArrayList(spec.getScalaClasspath())));
    spec.setZincClasspath(new SimpleFileCollection(Lists.newArrayList(spec.getZincClasspath())));

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Class path: {}", spec.getClasspath());
        LOGGER.debug("Scala class path: {}", spec.getScalaClasspath());
        LOGGER.debug("Zinc class path: {}", spec.getZincClasspath());
    }
}
项目:Pushjet-Android    文件:DefaultFileCollectionSnapshotter.java   
public FileCollection getFiles() {
    List<File> files = new ArrayList<File>();
    for (Map.Entry<String, FileSnapshot> entry : snapshots.entrySet()) {
        if (entry.getValue() instanceof FileHashSnapshot) {
            files.add(new File(entry.getKey()));
        }
    }
    return new SimpleFileCollection(files);
}
项目:Pushjet-Android    文件:NormalizingJavaCompiler.java   
private void resolveAndFilterSourceFiles(JavaCompileSpec spec) {
    // this mimics the behavior of the Ant javac task (and therefore AntJavaCompiler),
    // which silently excludes files not ending in .java
    FileCollection javaOnly = spec.getSource().filter(new Spec<File>() {
        public boolean isSatisfiedBy(File element) {
            return element.getName().endsWith(".java");
        }
    });

    spec.setSource(new SimpleFileCollection(javaOnly.getFiles()));
}
项目:Pushjet-Android    文件:NormalizingGroovyCompiler.java   
private void resolveAndFilterSourceFiles(final GroovyJavaJointCompileSpec spec) {
    FileCollection filtered = spec.getSource().filter(new Spec<File>() {
        public boolean isSatisfiedBy(File element) {
            for (String fileExtension : spec.getGroovyCompileOptions().getFileExtensions()) {
                if (element.getName().endsWith("." + fileExtension)) {
                    return true;
                }
            }
            return false;
        }
    });

    spec.setSource(new SimpleFileCollection(filtered.getFiles()));
}
项目: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());
}
项目:CodeColors    文件:IgnoreResFilesTaskActionWrapper.java   
@Override
public FileCollection getOutputFiles() {
    ArrayList<File> newOuputFiles = new ArrayList<>();
    for (File file : mTaskExecutionHistory.getOutputFiles()) {
        newOuputFiles.add(
                FileUtils.inFolder(file, mResFiles) ?
                        new IgnoreResFileFile(file.getPath(), mResFiles) : file);
    }
    return new SimpleFileCollection(newOuputFiles);
}
项目:checkstyle-addons    文件:DependencyConfigs.java   
private FileCollection readListOfDepConfigs(@Nonnull final File pDepConfigDir)
{
    File[] listOfFiles = pDepConfigDir.listFiles(new PropertyFileFilter());
    if (listOfFiles == null) {
        throw new GradleException("no dependency configurations found in dir: " + pDepConfigDir);
    }
    return new SimpleFileCollection(listOfFiles);
}
项目:Reer    文件:SourceSetNativeDependencyResolver.java   
private FileCollection empty() {
    return new SimpleFileCollection();
}
项目:Reer    文件:EmptyClasspath.java   
@Override
public FileCollection getFiles() {
    return new SimpleFileCollection();
}
项目:Reer    文件:NormalizingJavaCompiler.java   
private void resolveClasspath(JavaCompileSpec spec) {
    spec.setClasspath(new SimpleFileCollection(Lists.newArrayList(spec.getClasspath())));
}
项目:Reer    文件:NormalizingScalaCompiler.java   
private void resolveAndFilterSourceFiles(final ScalaJavaJointCompileSpec spec) {
    spec.setSource(new SimpleFileCollection(spec.getSource().getFiles()));
}
项目:Reer    文件:CacheableTaskOutputCompositeFilePropertyElementSpec.java   
public CacheableTaskOutputCompositeFilePropertyElementSpec(CompositeTaskOutputPropertySpec parentProperty, String propertySuffix, File file) {
    this.parentProperty = parentProperty;
    this.propertySuffix = propertySuffix;
    this.files = new SimpleFileCollection(Collections.singleton(file));
    this.file = file;
}
项目:Reer    文件:PlayTestPlugin.java   
@Mutate
void createTestTasks(ModelMap<Task> tasks, @Path("binaries") ModelMap<PlayApplicationBinarySpecInternal> playBinaries, final PlayPluginConfigurations configurations,
                     final FileResolver fileResolver, final ProjectIdentifier projectIdentifier, @Path("buildDir") final File buildDir) {
    for (final PlayApplicationBinarySpecInternal binary : playBinaries) {
        final PlayToolProvider playToolProvider = binary.getToolChain().select(binary.getTargetPlatform());
        final FileCollection testCompileClasspath = getTestCompileClasspath(binary, playToolProvider, configurations);

        final String testCompileTaskName = binary.getTasks().taskName("compile", "tests");
        final File testSourceDir = fileResolver.resolve("test");
        final FileCollection testSources = new SimpleFileCollection(testSourceDir).getAsFileTree().matching(new PatternSet().include("**/*.scala", "**/*.java"));
        final File testClassesDir = new File(buildDir, binary.getProjectScopedName() + "/testClasses");
        tasks.create(testCompileTaskName, PlatformScalaCompile.class, new Action<PlatformScalaCompile>() {
            public void execute(PlatformScalaCompile scalaCompile) {
                scalaCompile.setDescription("Compiles the scala and java test sources for the " + binary.getDisplayName() + ".");

                scalaCompile.setClasspath(testCompileClasspath);

                scalaCompile.dependsOn(binary.getBuildTask());
                scalaCompile.setPlatform(binary.getTargetPlatform().getScalaPlatform());
                scalaCompile.setDestinationDir(testClassesDir);
                scalaCompile.setSource(testSources);
                String targetCompatibility = binary.getTargetPlatform().getJavaPlatform().getTargetCompatibility().getMajorVersion();
                scalaCompile.setSourceCompatibility(targetCompatibility);
                scalaCompile.setTargetCompatibility(targetCompatibility);

                IncrementalCompileOptions incrementalOptions = scalaCompile.getScalaCompileOptions().getIncrementalOptions();
                incrementalOptions.setAnalysisFile(new File(buildDir, "tmp/scala/compilerAnalysis/" + testCompileTaskName + ".analysis"));
            }
        });

        final String testTaskName = binary.getTasks().taskName("test");
        final File binaryBuildDir = new File(buildDir, binary.getProjectScopedName());
        tasks.create(testTaskName, Test.class, new Action<Test>() {
            public void execute(Test test) {
                test.setDescription("Runs " + WordUtils.uncapitalize(binary.getDisplayName() + "."));

                test.setClasspath(getRuntimeClasspath(testClassesDir, testCompileClasspath));

                test.setTestClassesDir(testClassesDir);
                test.setBinResultsDir(new File(binaryBuildDir, "results/" + testTaskName + "/bin"));
                test.getReports().getJunitXml().setDestination(new File(binaryBuildDir, "reports/test/xml"));
                test.getReports().getHtml().setDestination(new File(binaryBuildDir, "reports/test"));
                test.dependsOn(testCompileTaskName);
                test.setWorkingDir(projectIdentifier.getProjectDir());
            }
        });
        binary.getTasks().add(tasks.get(testTaskName));
    }
}
项目:Reer    文件:PlayTestPlugin.java   
private FileCollection getTestCompileClasspath(PlayApplicationBinarySpec binary, PlayToolProvider playToolProvider, PlayPluginConfigurations configurations) {
    return new SimpleFileCollection(binary.getJarFile()).plus(configurations.getPlayTest().getAllArtifacts());
}
项目:Reer    文件:PlayTestPlugin.java   
private FileCollection getRuntimeClasspath(File testClassesDir, FileCollection testCompileClasspath) {
    return new SimpleFileCollection(testClassesDir).plus(testCompileClasspath);
}
项目:Reer    文件:SignOperation.java   
private FileCollection newSignatureFileCollection(Function<Signature, File> getFile) {
    return new SimpleFileCollection(collectSignatureFiles(getFile));
}
项目:Pushjet-Android    文件:NormalizingScalaCompiler.java   
private void resolveAndFilterSourceFiles(final ScalaJavaJointCompileSpec spec) {
    spec.setSource(new SimpleFileCollection(spec.getSource().getFiles()));
}
项目:Pushjet-Android    文件:SourceSetNativeDependencyResolver.java   
private FileCollection empty() {
    return new SimpleFileCollection();
}
项目:Pushjet-Android    文件:ApiRequirementNativeDependencyResolver.java   
public FileCollection getLinkFiles() {
    return new SimpleFileCollection();
}
项目:Pushjet-Android    文件:ApiRequirementNativeDependencyResolver.java   
public FileCollection getRuntimeFiles() {
    return new SimpleFileCollection();
}
项目:Pushjet-Android    文件:DefaultStaticLibraryBinarySpec.java   
public FileCollection getRuntimeFiles() {
    return new SimpleFileCollection();
}
项目:Pushjet-Android    文件:AbstractPrebuiltLibraryBinary.java   
public FileCollection getHeaderDirs() {
    return new SimpleFileCollection(library.getHeaders().getSrcDirs());
}
项目:Pushjet-Android    文件:DefaultPrebuiltStaticLibraryBinary.java   
public FileCollection getRuntimeFiles() {
    return new SimpleFileCollection();
}
项目:Pushjet-Android    文件:JavaCompilerArgumentsBuilder.java   
private FileCollection toFileCollection(Iterable<File> classpath) {
    if (classpath instanceof FileCollection) {
        return (FileCollection) classpath;
    }
    return new SimpleFileCollection(Lists.newArrayList(classpath));
}
项目:Pushjet-Android    文件:NormalizingJavaCompiler.java   
private void resolveClasspath(JavaCompileSpec spec) {
    spec.setClasspath(new SimpleFileCollection(Lists.newArrayList(spec.getClasspath())));
}
项目:Pushjet-Android    文件:DefaultJavaSourceSet.java   
public FileCollection getFiles() {
    return new SimpleFileCollection();
}
项目:Pushjet-Android    文件:DefaultTaskArtifactStateRepository.java   
public FileCollection getOutputFiles() {
    TaskExecution lastExecution = history.getPreviousExecution();
    return lastExecution != null && lastExecution.getOutputFilesSnapshot() != null ? lastExecution.getOutputFilesSnapshot().getFiles() : new SimpleFileCollection();
}