use of org.gradle.api.plugins.JavaBasePlugin 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());
}
});
}
});
}
use of org.gradle.api.plugins.JavaBasePlugin in project gradle by gradle.
the class EclipsePlugin method configureEclipseClasspath.
private void configureEclipseClasspath(final Project project, final EclipseModel model) {
model.setClasspath(project.getObjects().newInstance(EclipseClasspath.class, project));
((IConventionAware) model.getClasspath()).getConventionMapping().map("defaultOutputDir", new Callable<File>() {
@Override
public File call() {
return new File(project.getProjectDir(), EclipsePluginConstants.DEFAULT_PROJECT_OUTPUT_PATH);
}
});
model.getClasspath().getTestSourceSets().convention(testSourceSetsConvention);
model.getClasspath().getTestConfigurations().convention(testConfigurationsConvention);
project.getPlugins().withType(JavaBasePlugin.class, new Action<JavaBasePlugin>() {
@Override
public void execute(JavaBasePlugin javaBasePlugin) {
final TaskProvider<GenerateEclipseClasspath> task = project.getTasks().register(ECLIPSE_CP_TASK_NAME, GenerateEclipseClasspath.class, model.getClasspath());
task.configure(new Action<GenerateEclipseClasspath>() {
@Override
public void execute(final GenerateEclipseClasspath task) {
task.setDescription("Generates the Eclipse classpath file.");
task.setInputFile(project.file(".classpath"));
task.setOutputFile(project.file(".classpath"));
}
});
addWorker(task, ECLIPSE_CP_TASK_NAME);
XmlTransformer xmlTransformer = new XmlTransformer();
xmlTransformer.setIndentation("\t");
model.getClasspath().setFile(new XmlFileContentMerger(xmlTransformer));
model.getClasspath().setSourceSets(project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets());
AfterEvaluateHelper.afterEvaluateOrExecute(project, new Action<Project>() {
@Override
public void execute(Project p) {
// keep the ordering we had in earlier gradle versions
Set<String> containers = Sets.newLinkedHashSet();
containers.add("org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/" + model.getJdt().getJavaRuntimeName() + "/");
containers.addAll(model.getClasspath().getContainers());
model.getClasspath().setContainers(containers);
}
});
configureScalaDependencies(project, model);
configureJavaClasspath(project, task, model, testSourceSetsConvention, testConfigurationsConvention);
}
});
}
Aggregations