use of org.gradle.api.internal.file.collections.SimpleFileCollection in project gradle by gradle.
the class NormalizingGroovyCompiler method resolveAndFilterSourceFiles.
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()));
}
use of org.gradle.api.internal.file.collections.SimpleFileCollection in project gradle by gradle.
the class IncrementalCompilationInitializer method initializeCompilation.
public void initializeCompilation(JavaCompileSpec spec, Collection<String> staleClasses) {
if (staleClasses.isEmpty()) {
spec.setSource(new SimpleFileCollection());
//do nothing. No classes need recompilation.
return;
}
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
List<File> classpath = Lists.newArrayList(spec.getCompileClasspath());
classpath.add(spec.getDestinationDir());
spec.setCompileClasspath(classpath);
//get rid of stale files
FileTree deleteMe = fileOperations.fileTree(spec.getDestinationDir()).matching(classesToDelete);
fileOperations.delete(deleteMe);
}
use of org.gradle.api.internal.file.collections.SimpleFileCollection in project gradle by gradle.
the class NormalizingJavaCompiler method resolveAndFilterSourceFiles.
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()));
}
use of org.gradle.api.internal.file.collections.SimpleFileCollection in project gradle by gradle.
the class IncrementalCompilationInitializer method initializeCompilation.
public void initializeCompilation(JavaCompileSpec spec, RecompilationSpec recompilationSpec) {
if (!recompilationSpec.isBuildNeeded()) {
spec.setSource(new SimpleFileCollection());
spec.setClasses(Collections.<String>emptySet());
return;
}
Factory<PatternSet> patternSetFactory = fileOperations.getFileResolver().getPatternSetFactory();
PatternSet classesToDelete = patternSetFactory.create();
PatternSet sourceToCompile = patternSetFactory.create();
preparePatterns(recompilationSpec.getClassesToCompile(), classesToDelete, sourceToCompile);
narrowDownSourcesToCompile(spec, sourceToCompile);
includePreviousCompilationOutputOnClasspath(spec);
addClassesToProcess(spec, recompilationSpec);
deleteStaleFilesIn(classesToDelete, spec.getDestinationDir());
deleteStaleFilesIn(classesToDelete, spec.getCompileOptions().getAnnotationProcessorGeneratedSourcesDirectory());
}
use of org.gradle.api.internal.file.collections.SimpleFileCollection in project gradle by gradle.
the class CompileOptions method setBootClasspath.
/**
* Sets the bootstrap classpath to be used for the compiler process. Defaults to {@code null}.
*
* @deprecated Use {@link #setBootstrapClasspath(FileCollection)} instead.
*/
@Deprecated
public void setBootClasspath(String bootClasspath) {
DeprecationLogger.nagUserOfReplacedProperty("CompileOptions.bootClasspath", "CompileOptions.bootstrapClasspath");
if (bootClasspath == null) {
this.bootstrapClasspath = null;
} else {
String[] paths = StringUtils.split(bootClasspath, File.pathSeparatorChar);
List<File> files = Lists.newArrayListWithCapacity(paths.length);
for (String path : paths) {
files.add(new File(path));
}
this.bootstrapClasspath = new SimpleFileCollection(files);
}
}
Aggregations