use of org.gradle.api.tasks.util.PatternSet in project gradle by gradle.
the class WindowsResourcesCompileTaskConfig method configureResourceCompileTask.
private void configureResourceCompileTask(WindowsResourceCompile task, final NativeBinarySpecInternal binary, final WindowsResourceSet sourceSet) {
task.setDescription("Compiles resources of the " + sourceSet + " of " + binary);
task.getToolChain().set(binary.getToolChain());
task.getTargetPlatform().set(binary.getTargetPlatform());
task.includes(sourceSet.getExportedHeaders().getSourceDirectories());
FileCollectionFactory fileCollectionFactory = ((ProjectInternal) task.getProject()).getServices().get(FileCollectionFactory.class);
task.includes(fileCollectionFactory.create(new MinimalFileSet() {
@Override
public Set<File> getFiles() {
PlatformToolProvider platformToolProvider = ((NativeToolChainInternal) binary.getToolChain()).select((NativePlatformInternal) binary.getTargetPlatform());
return new LinkedHashSet<File>(platformToolProvider.getSystemLibraries(ToolType.WINDOW_RESOURCES_COMPILER).getIncludeDirs());
}
@Override
public String getDisplayName() {
return "System includes for " + binary.getToolChain().getDisplayName();
}
}));
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);
}
}
use of org.gradle.api.tasks.util.PatternSet in project gradle by gradle.
the class DirectoryFileTree method filter.
public DirectoryFileTree filter(PatternFilterable patterns) {
PatternSet patternSet = this.patternSet.intersect();
patternSet.copyFrom(patterns);
return new DirectoryFileTree(dir, patternSet, directoryWalkerFactory, fileSystem, postfix);
}
use of org.gradle.api.tasks.util.PatternSet 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.tasks.util.PatternSet in project gradle by gradle.
the class DefaultScalaJavaJointCompiler method execute.
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;
}
};
}
use of org.gradle.api.tasks.util.PatternSet in project gradle by gradle.
the class DefaultFileSystemSnapshotter method snapshotDirectoryTree.
/*
* For simplicity this only caches trees without includes/excludes. However, if it is asked
* to snapshot a filtered tree, it will try to find a snapshot for the underlying
* tree and filter it in memory instead of walking the file system again. This covers the
* majority of cases, because all task outputs are put into the cache without filters
* before any downstream task uses them.
*/
@Override
public FileTreeSnapshot snapshotDirectoryTree(final DirectoryFileTree dirTree) {
// Could potentially coordinate with a thread that is snapshotting an overlapping directory tree
final String path = dirTree.getDir().getAbsolutePath();
final PatternSet patterns = dirTree.getPatterns();
FileTreeSnapshot snapshot = fileSystemMirror.getDirectoryTree(path);
if (snapshot != null) {
return filterSnapshot(snapshot, patterns);
}
if (!patterns.isEmpty()) {
return snapshotWithoutCaching(dirTree);
}
return producingTrees.guardByKey(path, new Factory<FileTreeSnapshot>() {
@Override
public FileTreeSnapshot create() {
FileTreeSnapshot snapshot = fileSystemMirror.getDirectoryTree(path);
if (snapshot == null) {
return snapshotAndCache(dirTree);
} else {
return snapshot;
}
}
});
}
Aggregations