Search in sources :

Example 1 with LinkedResourcesCreator

use of org.gradle.plugins.ide.eclipse.internal.LinkedResourcesCreator in project gradle by gradle.

the class EclipsePlugin method configureEclipseProject.

private void configureEclipseProject(final Project project, final EclipseModel model) {
    maybeAddTask(project, this, ECLIPSE_PROJECT_TASK_NAME, GenerateEclipseProject.class, new Action<GenerateEclipseProject>() {

        @Override
        public void execute(GenerateEclipseProject task) {
            final EclipseProject projectModel = task.getProjectModel();
            //task properties:
            task.setDescription("Generates the Eclipse project file.");
            task.setInputFile(project.file(".project"));
            task.setOutputFile(project.file(".project"));
            //model:
            model.setProject(projectModel);
            projectModel.setName(project.getName());
            final ConventionMapping convention = ((IConventionAware) projectModel).getConventionMapping();
            convention.map("comment", new Callable<String>() {

                @Override
                public String call() {
                    return project.getDescription();
                }
            });
            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");
                }
            });
        }
    });
}
Also used : EclipseProject(org.gradle.plugins.ide.eclipse.model.EclipseProject) Action(org.gradle.api.Action) Set(java.util.Set) ScalaBasePlugin(org.gradle.api.plugins.scala.ScalaBasePlugin) ConventionMapping(org.gradle.api.internal.ConventionMapping) Callable(java.util.concurrent.Callable) Predicate(com.google.common.base.Predicate) LinkedResourcesCreator(org.gradle.plugins.ide.eclipse.internal.LinkedResourcesCreator) GroovyBasePlugin(org.gradle.api.plugins.GroovyBasePlugin) JavaBasePlugin(org.gradle.api.plugins.JavaBasePlugin) BuildCommand(org.gradle.plugins.ide.eclipse.model.BuildCommand) EarPlugin(org.gradle.plugins.ear.EarPlugin)

Aggregations

Predicate (com.google.common.base.Predicate)1 Set (java.util.Set)1 Callable (java.util.concurrent.Callable)1 Action (org.gradle.api.Action)1 ConventionMapping (org.gradle.api.internal.ConventionMapping)1 GroovyBasePlugin (org.gradle.api.plugins.GroovyBasePlugin)1 JavaBasePlugin (org.gradle.api.plugins.JavaBasePlugin)1 ScalaBasePlugin (org.gradle.api.plugins.scala.ScalaBasePlugin)1 EarPlugin (org.gradle.plugins.ear.EarPlugin)1 LinkedResourcesCreator (org.gradle.plugins.ide.eclipse.internal.LinkedResourcesCreator)1 BuildCommand (org.gradle.plugins.ide.eclipse.model.BuildCommand)1 EclipseProject (org.gradle.plugins.ide.eclipse.model.EclipseProject)1