use of org.gradle.plugins.ide.eclipse.internal.EclipseProjectMetadata in project gradle by gradle.
the class EclipsePlugin method configureEclipseProject.
private void configureEclipseProject(final ProjectInternal project, final EclipseModel model) {
final EclipseProject projectModel = model.getProject();
projectModel.setName(uniqueProjectNameProvider.getUniqueName(project));
final ConventionMapping convention = ((IConventionAware) projectModel).getConventionMapping();
convention.map("comment", new Callable<String>() {
@Override
public String call() {
return project.getDescription();
}
});
final TaskProvider<GenerateEclipseProject> task = project.getTasks().register(ECLIPSE_PROJECT_TASK_NAME, GenerateEclipseProject.class, model.getProject());
task.configure(new Action<GenerateEclipseProject>() {
@Override
public void execute(GenerateEclipseProject task) {
task.setDescription("Generates the Eclipse project file.");
task.setInputFile(project.file(".project"));
task.setOutputFile(project.file(".project"));
}
});
addWorker(task, ECLIPSE_PROJECT_TASK_NAME);
project.getPlugins().withType(JavaBasePlugin.class, new Action<JavaBasePlugin>() {
@Override
public void execute(JavaBasePlugin javaBasePlugin) {
if (!project.getPlugins().hasPlugin(EarPlugin.class)) {
projectModel.buildCommand("org.eclipse.jdt.core.javabuilder");
}
projectModel.natures("org.eclipse.jdt.core.javanature");
convention.map("linkedResources", new Callable<Set<Link>>() {
@Override
public Set<Link> call() {
return new LinkedResourcesCreator().links(project);
}
});
}
});
project.getPlugins().withType(GroovyBasePlugin.class, new Action<GroovyBasePlugin>() {
@Override
public void execute(GroovyBasePlugin groovyBasePlugin) {
projectModel.getNatures().add(projectModel.getNatures().indexOf("org.eclipse.jdt.core.javanature"), "org.eclipse.jdt.groovy.core.groovyNature");
}
});
project.getPlugins().withType(ScalaBasePlugin.class, new Action<ScalaBasePlugin>() {
@Override
public void execute(ScalaBasePlugin scalaBasePlugin) {
projectModel.getBuildCommands().set(Iterables.indexOf(projectModel.getBuildCommands(), new Predicate<BuildCommand>() {
@Override
public boolean apply(BuildCommand buildCommand) {
return buildCommand.getName().equals("org.eclipse.jdt.core.javabuilder");
}
}), new BuildCommand("org.scala-ide.sdt.core.scalabuilder"));
projectModel.getNatures().add(projectModel.getNatures().indexOf("org.eclipse.jdt.core.javanature"), "org.scala-ide.sdt.core.scalanature");
}
});
artifactRegistry.registerIdeProject(new EclipseProjectMetadata(model, project.getProjectDir(), task));
}
Aggregations