use of org.gradle.api.file.FileCollection 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.file.FileCollection in project gradle by gradle.
the class GroovyCompile method calculateAnnotationProcessorClasspath.
private List<File> calculateAnnotationProcessorClasspath() {
AnnotationProcessorDetector annotationProcessorDetector = getServices().get(AnnotationProcessorDetector.class);
FileCollection processorClasspath = annotationProcessorDetector.getEffectiveAnnotationProcessorClasspath(compileOptions, getClasspath());
return Lists.newArrayList(processorClasspath);
}
use of org.gradle.api.file.FileCollection 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.file.FileCollection in project gradle by gradle.
the class ShadedJar method run.
@TaskAction
public void run() throws Exception {
long start = System.currentTimeMillis();
PrintWriter writer = new PrintWriter(analysisFile);
try {
final ClassGraph classes = new ClassGraph(new PackagePatterns(keepPackages), new PackagePatterns(unshadedPackages), new PackagePatterns(ignorePackages), shadowPackage);
List<FileCollection> classFiles = new ArrayList<>();
for (File sourceFile : sourceFiles) {
classFiles.add(getProject().zipTree(sourceFile));
}
analyse(getProject().files(classFiles), classes, writer);
writeJar(classes, classesDir, jarFile, writer);
} finally {
writer.close();
}
long end = System.currentTimeMillis();
System.out.println("Analysis took " + (end - start) + "ms.");
}
use of org.gradle.api.file.FileCollection in project gradle by gradle.
the class CompositeFileCollectionTest method filterDelegatesToEachSet.
@Test
public void filterDelegatesToEachSet() {
final FileCollectionInternal filtered1 = context.mock(FileCollectionInternal.class);
final FileCollectionInternal filtered2 = context.mock(FileCollectionInternal.class);
@SuppressWarnings("unchecked") final Spec<File> spec = context.mock(Spec.class);
FileCollection filtered = collection.filter(spec);
assertThat(filtered, instanceOf(CompositeFileCollection.class));
context.checking(new Expectations() {
{
oneOf(source1).filter(spec);
will(returnValue(filtered1));
oneOf(source2).filter(spec);
will(returnValue(filtered2));
}
});
assertThat(((CompositeFileCollection) filtered).getSourceCollections(), equalTo((Iterable) toList(filtered1, filtered2)));
}
Aggregations