Search in sources :

Example 1 with PlayApplicationBinarySpecInternal

use of org.gradle.play.internal.PlayApplicationBinarySpecInternal in project gradle by gradle.

the class PlayDistributionPlugin method createDistributions.

@Defaults
void createDistributions(@Path("distributions") PlayDistributionContainer distributions, @Path("binaries") ModelMap<PlayApplicationBinarySpecInternal> playBinaries, PlayPluginConfigurations configurations, ServiceRegistry serviceRegistry) {
    FileOperations fileOperations = serviceRegistry.get(FileOperations.class);
    Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    for (PlayApplicationBinarySpecInternal binary : playBinaries) {
        PlayDistribution distribution = instantiator.newInstance(DefaultPlayDistribution.class, binary.getProjectScopedName(), fileOperations.copySpec(), binary);
        distribution.setBaseName(binary.getProjectScopedName());
        distributions.add(distribution);
    }
}
Also used : PlayApplicationBinarySpecInternal(org.gradle.play.internal.PlayApplicationBinarySpecInternal) FileOperations(org.gradle.api.internal.file.FileOperations) PlayDistribution(org.gradle.play.distribution.PlayDistribution) DefaultPlayDistribution(org.gradle.play.internal.distribution.DefaultPlayDistribution) Instantiator(org.gradle.internal.reflect.Instantiator)

Example 2 with PlayApplicationBinarySpecInternal

use of org.gradle.play.internal.PlayApplicationBinarySpecInternal 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.setTestClassesDir(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

PlayApplicationBinarySpecInternal (org.gradle.play.internal.PlayApplicationBinarySpecInternal)2 File (java.io.File)1 FileCollection (org.gradle.api.file.FileCollection)1 FileOperations (org.gradle.api.internal.file.FileOperations)1 SimpleFileCollection (org.gradle.api.internal.file.collections.SimpleFileCollection)1 IncrementalCompileOptions (org.gradle.api.tasks.scala.IncrementalCompileOptions)1 Test (org.gradle.api.tasks.testing.Test)1 PatternSet (org.gradle.api.tasks.util.PatternSet)1 Instantiator (org.gradle.internal.reflect.Instantiator)1 PlatformScalaCompile (org.gradle.language.scala.tasks.PlatformScalaCompile)1 Mutate (org.gradle.model.Mutate)1 PlayDistribution (org.gradle.play.distribution.PlayDistribution)1 DefaultPlayDistribution (org.gradle.play.internal.distribution.DefaultPlayDistribution)1 PlayToolProvider (org.gradle.play.internal.toolchain.PlayToolProvider)1