use of org.gradle.plugins.ide.api.PropertiesFileContentMerger in project gradle-apt-plugin by tbroyer.
the class AptEclipsePlugin method configureJdtApt.
private void configureJdtApt(final Project project, EclipseModel eclipseModel, final SourceSet mainSourceSet) {
final EclipseJdtApt jdtApt = ((ExtensionAware) eclipseModel.getJdt()).getExtensions().create("apt", EclipseJdtApt.class, project, new PropertiesFileContentMerger(new PropertiesTransformer()));
jdtApt.setAptEnabled(project.provider(() -> project.getTasks().getByName(mainSourceSet.getCompileJavaTaskName()).getExtensions().getByType(AptPlugin.AptOptions.class).isAnnotationProcessing()));
jdtApt.setProcessorOptions(() -> project.getTasks().getByName(mainSourceSet.getCompileJavaTaskName()).getExtensions().getByType(AptPlugin.AptOptions.class).getProcessorArgs());
eclipseModel.getJdt().getFile().withProperties(properties -> properties.setProperty("org.eclipse.jdt.core.compiler.processAnnotations", jdtApt.isAptEnabled() ? "enabled" : "disabled"));
final Object task = AptPlugin.IMPL.createTask(project, "eclipseJdtApt", GenerateEclipseJdtApt.class, generateEclipseJdtApt -> {
generateEclipseJdtApt.setDescription("Generates the Eclipse JDT APT settings file.");
generateEclipseJdtApt.setInputFile(project.file(".settings/org.eclipse.jdt.apt.core.prefs"));
generateEclipseJdtApt.setOutputFile(project.file(".settings/org.eclipse.jdt.apt.core.prefs"));
generateEclipseJdtApt.setJdtApt(jdtApt);
});
AptPlugin.IMPL.configureTask(project, Task.class, "eclipse", dependsOn(task));
final Object cleanTask = AptPlugin.IMPL.createTask(project, "cleanEclipseJdtApt", Delete.class, cleanEclipseJdtApt -> cleanEclipseJdtApt.delete(task));
AptPlugin.IMPL.configureTask(project, Task.class, "cleanEclipse", dependsOn(cleanTask));
}
use of org.gradle.plugins.ide.api.PropertiesFileContentMerger in project gradle by gradle.
the class EclipsePlugin method configureEclipseJdt.
private void configureEclipseJdt(final Project project, final EclipseModel model) {
project.getPlugins().withType(JavaBasePlugin.class, new Action<JavaBasePlugin>() {
@Override
public void execute(JavaBasePlugin javaBasePlugin) {
model.setJdt(project.getObjects().newInstance(EclipseJdt.class, new PropertiesFileContentMerger(new PropertiesTransformer())));
final TaskProvider<GenerateEclipseJdt> task = project.getTasks().register(ECLIPSE_JDT_TASK_NAME, GenerateEclipseJdt.class, model.getJdt());
task.configure(new Action<GenerateEclipseJdt>() {
@Override
public void execute(GenerateEclipseJdt task) {
// task properties:
task.setDescription("Generates the Eclipse JDT settings file.");
task.setOutputFile(project.file(".settings/org.eclipse.jdt.core.prefs"));
task.setInputFile(project.file(".settings/org.eclipse.jdt.core.prefs"));
}
});
addWorker(task, ECLIPSE_JDT_TASK_NAME);
// model properties:
ConventionMapping conventionMapping = ((IConventionAware) model.getJdt()).getConventionMapping();
conventionMapping.map("sourceCompatibility", new Callable<JavaVersion>() {
@Override
public JavaVersion call() {
return project.getExtensions().getByType(JavaPluginExtension.class).getSourceCompatibility();
}
});
conventionMapping.map("targetCompatibility", new Callable<JavaVersion>() {
@Override
public JavaVersion call() {
return project.getExtensions().getByType(JavaPluginExtension.class).getTargetCompatibility();
}
});
conventionMapping.map("javaRuntimeName", new Callable<String>() {
@Override
public String call() {
return eclipseJavaRuntimeNameFor(project.getExtensions().getByType(JavaPluginExtension.class).getTargetCompatibility());
}
});
}
});
}
Aggregations