use of org.gradle.api.file.FileTree in project gradle by gradle.
the class CopySpecActionImpl method execute.
@Override
public void execute(final CopySpecResolver specResolver) {
FileTree source = specResolver.getSource();
source.visit(new CopyFileVisitorImpl(specResolver, action, instantiator, objectFactory, fileSystem, reproducibleFileOrder));
}
use of org.gradle.api.file.FileTree 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.getCompilerArgs().set(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.file.FileTree in project gradle by gradle.
the class PrecompiledGroovyPluginsPlugin method exposeScriptsAsPlugins.
private void exposeScriptsAsPlugins(Project project) {
GradlePluginDevelopmentExtension pluginExtension = project.getExtensions().getByType(GradlePluginDevelopmentExtension.class);
SourceSet pluginSourceSet = pluginExtension.getPluginSourceSet();
FileTree scriptPluginFiles = pluginSourceSet.getAllSource().matching(PrecompiledGroovyScript::filterPluginFiles);
List<PrecompiledGroovyScript> scriptPlugins = scriptPluginFiles.getFiles().stream().map(file -> new PrecompiledGroovyScript(file, getTextFileResourceLoader())).peek(scriptPlugin -> validateScriptPlugin(project, scriptPlugin)).collect(Collectors.toList());
declarePluginMetadata(pluginExtension, scriptPlugins);
DirectoryProperty buildDir = project.getLayout().getBuildDirectory();
TaskContainer tasks = project.getTasks();
TaskProvider<ExtractPluginRequestsTask> extractPluginRequests = tasks.register("extractPluginRequests", ExtractPluginRequestsTask.class, task -> {
task.getScriptPlugins().convention(scriptPlugins);
task.getScriptFiles().from(scriptPluginFiles.getFiles());
task.getExtractedPluginRequestsClassesDirectory().convention(buildDir.dir("groovy-dsl-plugins/output/plugin-requests"));
task.getExtractedPluginRequestsClassesStagingDirectory().convention(buildDir.dir("groovy-dsl-plugins/output/plugin-requests-staging"));
});
TaskProvider<GeneratePluginAdaptersTask> generatePluginAdapters = tasks.register("generatePluginAdapters", GeneratePluginAdaptersTask.class, task -> {
task.getScriptPlugins().convention(scriptPlugins);
task.getExtractedPluginRequestsClassesDirectory().convention(extractPluginRequests.flatMap(ExtractPluginRequestsTask::getExtractedPluginRequestsClassesDirectory));
task.getPluginAdapterSourcesOutputDirectory().convention(buildDir.dir("groovy-dsl-plugins/output/adapter-src"));
});
TaskProvider<CompileGroovyScriptPluginsTask> precompilePlugins = tasks.register("compileGroovyPlugins", CompileGroovyScriptPluginsTask.class, task -> {
task.getScriptPlugins().convention(scriptPlugins);
task.getScriptFiles().from(scriptPluginFiles.getFiles());
task.getPrecompiledGroovyScriptsOutputDirectory().convention(buildDir.dir("groovy-dsl-plugins/output/plugin-classes"));
SourceDirectorySet javaSource = pluginSourceSet.getJava();
SourceDirectorySet groovySource = pluginSourceSet.getExtensions().getByType(GroovySourceDirectorySet.class);
task.getClasspath().from(pluginSourceSet.getCompileClasspath(), javaSource.getClassesDirectory(), groovySource.getClassesDirectory());
});
pluginSourceSet.getJava().srcDir(generatePluginAdapters.flatMap(GeneratePluginAdaptersTask::getPluginAdapterSourcesOutputDirectory));
pluginSourceSet.getOutput().dir(precompilePlugins.flatMap(CompileGroovyScriptPluginsTask::getPrecompiledGroovyScriptsOutputDirectory));
pluginSourceSet.getOutput().dir(extractPluginRequests.flatMap(ExtractPluginRequestsTask::getExtractedPluginRequestsClassesStagingDirectory));
}
use of org.gradle.api.file.FileTree in project gradle by gradle.
the class DefaultTestExecuter method execute.
@Override
public void execute(final JvmTestExecutionSpec testExecutionSpec, TestResultProcessor testResultProcessor) {
final TestFramework testFramework = testExecutionSpec.getTestFramework();
final WorkerTestClassProcessorFactory testInstanceFactory = testFramework.getProcessorFactory();
final Set<File> classpath = ImmutableSet.copyOf(testExecutionSpec.getClasspath());
final Set<File> modulePath = ImmutableSet.copyOf(testExecutionSpec.getModulePath());
final List<String> testWorkerImplementationModules = testFramework.getTestWorkerImplementationModules();
final Factory<TestClassProcessor> forkingProcessorFactory = new Factory<TestClassProcessor>() {
@Override
public TestClassProcessor create() {
return new ForkingTestClassProcessor(workerLeaseService, workerFactory, testInstanceFactory, testExecutionSpec.getJavaForkOptions(), classpath, modulePath, testWorkerImplementationModules, testFramework.getWorkerConfigurationAction(), moduleRegistry, documentationRegistry);
}
};
final Factory<TestClassProcessor> reforkingProcessorFactory = new Factory<TestClassProcessor>() {
@Override
public TestClassProcessor create() {
return new RestartEveryNTestClassProcessor(forkingProcessorFactory, testExecutionSpec.getForkEvery());
}
};
processor = new PatternMatchTestClassProcessor(testFilter, new RunPreviousFailedFirstTestClassProcessor(testExecutionSpec.getPreviousFailedTestClasses(), new MaxNParallelTestClassProcessor(getMaxParallelForks(testExecutionSpec), reforkingProcessorFactory, actorFactory)));
final FileTree testClassFiles = testExecutionSpec.getCandidateClassFiles();
Runnable detector;
if (testExecutionSpec.isScanForTestClasses() && testFramework.getDetector() != null) {
TestFrameworkDetector testFrameworkDetector = testFramework.getDetector();
testFrameworkDetector.setTestClasses(testExecutionSpec.getTestClassesDirs().getFiles());
testFrameworkDetector.setTestClasspath(classpath);
detector = new DefaultTestClassScanner(testClassFiles, testFrameworkDetector, processor);
} else {
detector = new DefaultTestClassScanner(testClassFiles, null, processor);
}
new TestMainAction(detector, processor, testResultProcessor, workerLeaseService, clock, testExecutionSpec.getPath(), "Gradle Test Run " + testExecutionSpec.getIdentityPath()).run();
}
use of org.gradle.api.file.FileTree in project gradle by gradle.
the class CompositeFileCollectionTest method getAsFileTreeDelegatesToEachSet.
@Test
public void getAsFileTreeDelegatesToEachSet() {
final File file1 = new File("dir1");
final File file2 = new File("dir2");
FileTree fileTree = collection.getAsFileTree();
assertThat(fileTree, instanceOf(CompositeFileTree.class));
context.checking(new Expectations() {
{
oneOf(source1).getFiles();
will(returnValue(toSet(file1)));
oneOf(source2).getFiles();
will(returnValue(toSet(file2)));
}
});
((CompositeFileTree) fileTree).getSourceCollections();
}
Aggregations