Search in sources :

Example 11 with PatternSet

use of org.gradle.api.tasks.util.PatternSet in project gradle by gradle.

the class AbstractFileTree method matching.

@Override
public FileTree matching(Action<? super PatternFilterable> filterConfigAction) {
    PatternSet patternSet = patternSetFactory.create();
    filterConfigAction.execute(patternSet);
    return matching(patternSet);
}
Also used : PatternSet(org.gradle.api.tasks.util.PatternSet)

Example 12 with PatternSet

use of org.gradle.api.tasks.util.PatternSet 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());
}
Also used : SimpleFileCollection(org.gradle.api.internal.file.collections.SimpleFileCollection) PatternSet(org.gradle.api.tasks.util.PatternSet)

Example 13 with PatternSet

use of org.gradle.api.tasks.util.PatternSet in project gradle by gradle.

the class SourceCompileTaskConfig method configureCompileTask.

@Override
protected void configureCompileTask(AbstractNativeCompileTask abstractTask, final NativeBinarySpecInternal binary, final LanguageSourceSetInternal sourceSet) {
    AbstractNativeSourceCompileTask task = (AbstractNativeSourceCompileTask) abstractTask;
    task.setDescription("Compiles the " + sourceSet + " of " + binary);
    task.source(sourceSet.getSource());
    final Project project = task.getProject();
    task.getObjectFileDir().set(new File(binary.getNamingScheme().getOutputDirectory(project.getBuildDir(), "objs"), sourceSet.getProjectScopedName()));
    // If this task uses a pre-compiled header
    if (sourceSet instanceof DependentSourceSetInternal && ((DependentSourceSetInternal) sourceSet).getPreCompiledHeader() != null) {
        final DependentSourceSetInternal dependentSourceSet = (DependentSourceSetInternal) sourceSet;
        PreCompiledHeader pch = binary.getPrefixFileToPCH().get(dependentSourceSet.getPrefixHeaderFile());
        pch.setPrefixHeaderFile(dependentSourceSet.getPrefixHeaderFile());
        pch.setIncludeString(dependentSourceSet.getPreCompiledHeader());
        task.setPreCompiledHeader(pch);
    }
    binary.binaryInputs(task.getOutputs().getFiles().getAsFileTree().matching(new PatternSet().include("**/*.obj", "**/*.o")));
}
Also used : Project(org.gradle.api.Project) PreCompiledHeader(org.gradle.nativeplatform.toolchain.internal.PreCompiledHeader) AbstractNativeSourceCompileTask(org.gradle.language.nativeplatform.tasks.AbstractNativeSourceCompileTask) ObjectFile(org.gradle.nativeplatform.ObjectFile) File(java.io.File) PatternSet(org.gradle.api.tasks.util.PatternSet)

Example 14 with PatternSet

use of org.gradle.api.tasks.util.PatternSet in project gradle by gradle.

the class PlayTestPlugin method createTestTasks.

@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.setTestClassesDirs(new SimpleFileCollection(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));
    }
}
Also used : PlatformScalaCompile(org.gradle.language.scala.tasks.PlatformScalaCompile) IncrementalCompileOptions(org.gradle.api.tasks.scala.IncrementalCompileOptions) PlayApplicationBinarySpecInternal(org.gradle.play.internal.PlayApplicationBinarySpecInternal) Test(org.gradle.api.tasks.testing.Test) SimpleFileCollection(org.gradle.api.internal.file.collections.SimpleFileCollection) PlayToolProvider(org.gradle.play.internal.toolchain.PlayToolProvider) SimpleFileCollection(org.gradle.api.internal.file.collections.SimpleFileCollection) FileCollection(org.gradle.api.file.FileCollection) File(java.io.File) PatternSet(org.gradle.api.tasks.util.PatternSet) Mutate(org.gradle.model.Mutate)

Aggregations

PatternSet (org.gradle.api.tasks.util.PatternSet)14 File (java.io.File)7 Project (org.gradle.api.Project)4 FileTree (org.gradle.api.file.FileTree)4 SimpleFileCollection (org.gradle.api.internal.file.collections.SimpleFileCollection)3 LinkedHashSet (java.util.LinkedHashSet)2 FileCollectionFactory (org.gradle.api.internal.file.FileCollectionFactory)2 MinimalFileSet (org.gradle.api.internal.file.collections.MinimalFileSet)2 ObjectFile (org.gradle.nativeplatform.ObjectFile)2 NativeToolChainInternal (org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal)2 PlatformToolProvider (org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider)2 PreCompiledHeader (org.gradle.nativeplatform.toolchain.internal.PreCompiledHeader)2 GradleException (org.gradle.api.GradleException)1 FileCollection (org.gradle.api.file.FileCollection)1 RelativePath (org.gradle.api.file.RelativePath)1 PatternStep (org.gradle.api.internal.file.pattern.PatternStep)1 Spec (org.gradle.api.specs.Spec)1 WorkResult (org.gradle.api.tasks.WorkResult)1 IncrementalCompileOptions (org.gradle.api.tasks.scala.IncrementalCompileOptions)1 Test (org.gradle.api.tasks.testing.Test)1