Search in sources :

Example 36 with FileCollection

use of org.gradle.api.file.FileCollection in project gradle by gradle.

the class NativeSpecVisualStudioTargetBinary method getHeaderFiles.

@Override
public FileCollection getHeaderFiles() {
    Spec<LanguageSourceSet> filter = new Spec<LanguageSourceSet>() {

        @Override
        public boolean isSatisfiedBy(LanguageSourceSet sourceSet) {
            return sourceSet instanceof HeaderExportingSourceSet;
        }
    };
    Transformer<FileCollection, LanguageSourceSet> transform = new Transformer<FileCollection, LanguageSourceSet>() {

        @Override
        public FileCollection transform(LanguageSourceSet sourceSet) {
            HeaderExportingSourceSet exportingSourceSet = (HeaderExportingSourceSet) sourceSet;
            return exportingSourceSet.getExportedHeaders().plus(exportingSourceSet.getImplicitHeaders());
        }
    };
    return new FileCollectionAdapter(new LanguageSourceSetCollectionAdapter(getComponentName() + " header files", binary.getInputs(), filter, transform));
}
Also used : LanguageSourceSet(org.gradle.language.base.LanguageSourceSet) Transformer(org.gradle.api.Transformer) FileCollectionAdapter(org.gradle.api.internal.file.collections.FileCollectionAdapter) HeaderExportingSourceSet(org.gradle.language.nativeplatform.HeaderExportingSourceSet) SharedLibraryBinarySpec(org.gradle.nativeplatform.SharedLibraryBinarySpec) NativeTestSuiteBinarySpec(org.gradle.nativeplatform.test.NativeTestSuiteBinarySpec) StaticLibraryBinarySpec(org.gradle.nativeplatform.StaticLibraryBinarySpec) Spec(org.gradle.api.specs.Spec) NativeExecutableBinarySpec(org.gradle.nativeplatform.NativeExecutableBinarySpec) NativeBinarySpec(org.gradle.nativeplatform.NativeBinarySpec) FileCollection(org.gradle.api.file.FileCollection) UnionFileCollection(org.gradle.api.internal.file.UnionFileCollection)

Example 37 with FileCollection

use of org.gradle.api.file.FileCollection in project gradle by gradle.

the class FindBugsPlugin method configureForSourceSet.

@Override
protected void configureForSourceSet(final SourceSet sourceSet, FindBugs task) {
    task.setDescription("Run FindBugs analysis for " + sourceSet.getName() + " classes");
    task.setSource(sourceSet.getAllJava());
    ConventionMapping taskMapping = task.getConventionMapping();
    taskMapping.map("classes", new Callable<FileCollection>() {

        @Override
        public FileCollection call() {
            return sourceSet.getOutput().getClassesDirs();
        }
    });
    taskMapping.map("classpath", new Callable<FileCollection>() {

        @Override
        public FileCollection call() {
            return sourceSet.getCompileClasspath();
        }
    });
}
Also used : FileCollection(org.gradle.api.file.FileCollection) ConventionMapping(org.gradle.api.internal.ConventionMapping)

Example 38 with FileCollection

use of org.gradle.api.file.FileCollection in project gradle by gradle.

the class War method classpath.

/**
 * Adds files to the classpath to include in the WAR archive.
 *
 * @param classpath The files to add. These are evaluated as per {@link org.gradle.api.Project#files(Object...)}
 */
public void classpath(Object... classpath) {
    FileCollection oldClasspath = getClasspath();
    this.classpath = getProject().files(oldClasspath != null ? oldClasspath : new ArrayList(), classpath);
}
Also used : ArrayList(java.util.ArrayList) FileCollection(org.gradle.api.file.FileCollection)

Example 39 with FileCollection

use of org.gradle.api.file.FileCollection 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

FileCollection (org.gradle.api.file.FileCollection)39 File (java.io.File)20 Callable (java.util.concurrent.Callable)6 ArrayList (java.util.ArrayList)5 ConventionMapping (org.gradle.api.internal.ConventionMapping)5 LinkedHashSet (java.util.LinkedHashSet)4 Set (java.util.Set)3 FileCollectionInternal (org.gradle.api.internal.file.FileCollectionInternal)3 SimpleFileCollection (org.gradle.api.internal.file.collections.SimpleFileCollection)3 CompileOptions (com.android.build.gradle.internal.CompileOptions)2 GlobalScope (com.android.build.gradle.internal.scope.GlobalScope)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Project (org.gradle.api.Project)2 Task (org.gradle.api.Task)2 Transformer (org.gradle.api.Transformer)2 Configuration (org.gradle.api.artifacts.Configuration)2 CompositeFileCollection (org.gradle.api.internal.file.CompositeFileCollection)2 MinimalFileSet (org.gradle.api.internal.file.collections.MinimalFileSet)2 Expectations (org.jmock.Expectations)2