use of org.gradle.model.Mutate in project gradle by gradle.
the class IvyPluginPublishingRules method addMainPublication.
@Mutate
public void addMainPublication(PublishingExtension publishing, GradlePluginDevelopmentExtension pluginDevelopment, ServiceRegistry services) {
if (!pluginDevelopment.isAutomatedPublishing()) {
return;
}
SoftwareComponentContainer componentContainer = services.get(SoftwareComponentContainer.class);
SoftwareComponent component = componentContainer.getByName("java");
PublicationContainer publications = publishing.getPublications();
createIvyPluginPublication(component, publications);
}
use of org.gradle.model.Mutate in project gradle by gradle.
the class PlayIdeaPlugin method configureIdeaModule.
@Mutate
public void configureIdeaModule(@Path("tasks.ideaModule") GenerateIdeaModule ideaModule, @Path("binaries.playBinary") final PlayApplicationBinarySpec playApplicationBinarySpec, @Path("buildDir") final File buildDir, ConfigurationContainer configurations, final FileResolver fileResolver) {
IdeaModule module = ideaModule.getModule();
module.setScopes(buildScopes(configurations));
ConventionMapping conventionMapping = conventionMappingFor(module);
conventionMapping.map("sourceDirs", new Callable<Set<File>>() {
@Override
public Set<File> call() throws Exception {
// TODO: Assets should probably be a source set too
Set<File> sourceDirs = Sets.newHashSet(playApplicationBinarySpec.getAssets().getAssetDirs());
return CollectionUtils.inject(sourceDirs, playApplicationBinarySpec.getInputs(), new Action<CollectionUtils.InjectionStep<Set<File>, LanguageSourceSet>>() {
@Override
public void execute(CollectionUtils.InjectionStep<Set<File>, LanguageSourceSet> step) {
step.getTarget().addAll(step.getItem().getSource().getSrcDirs());
}
});
}
});
conventionMapping.map("testSourceDirs", new Callable<Set<File>>() {
@Override
public Set<File> call() throws Exception {
// TODO: This should be modeled as a source set
return Collections.singleton(fileResolver.resolve("test"));
}
});
conventionMapping.map("singleEntryLibraries", new Callable<Map<String, Iterable<File>>>() {
@Override
public Map<String, Iterable<File>> call() throws Exception {
return ImmutableMap.<String, Iterable<File>>builder().put("COMPILE", Collections.singleton(playApplicationBinarySpec.getClasses().getClassesDir())).put("RUNTIME", playApplicationBinarySpec.getClasses().getResourceDirs()).put("TEST", Collections.singleton(new File(buildDir, "playBinary/testClasses"))).build();
}
});
module.setScalaPlatform(playApplicationBinarySpec.getTargetPlatform().getScalaPlatform());
conventionMapping.map("targetBytecodeVersion", new Callable<JavaVersion>() {
@Override
public JavaVersion call() throws Exception {
return getTargetJavaVersion(playApplicationBinarySpec);
}
});
conventionMapping.map("languageLevel", new Callable<IdeaLanguageLevel>() {
@Override
public IdeaLanguageLevel call() throws Exception {
return new IdeaLanguageLevel(getTargetJavaVersion(playApplicationBinarySpec));
}
});
ideaModule.dependsOn(playApplicationBinarySpec.getInputs());
ideaModule.dependsOn(playApplicationBinarySpec.getAssets());
}
use of org.gradle.model.Mutate 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));
}
}
use of org.gradle.model.Mutate in project gradle by gradle.
the class MavenPluginPublishingRules method addMainPublication.
@Mutate
public void addMainPublication(PublishingExtension publishing, GradlePluginDevelopmentExtension pluginDevelopment, ServiceRegistry services) {
if (!pluginDevelopment.isAutomatedPublishing()) {
return;
}
SoftwareComponentContainer componentContainer = services.get(SoftwareComponentContainer.class);
SoftwareComponent component = componentContainer.getByName("java");
PublicationContainer publications = publishing.getPublications();
createMavenPluginPublication(component, publications);
}
Aggregations