All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.xtext.gradle.idea.IdeaAggregatorPlugin Maven / Gradle / Ivy

There is a newer version: 2.0.9-alpha.3
Show newest version
package org.xtext.gradle.idea;

import java.io.File;
import java.util.Set;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.gradle.api.Action;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.file.FileCollection;
import org.gradle.api.plugins.BasePlugin;
import org.gradle.api.plugins.ExtensionContainer;
import org.gradle.api.plugins.PluginContainer;
import org.gradle.api.tasks.Sync;
import org.gradle.api.tasks.TaskContainer;
import org.gradle.api.tasks.TaskOutputs;
import org.xtext.gradle.idea.IdeaComponentPlugin;
import org.xtext.gradle.idea.IdeaDevelopmentPlugin;
import org.xtext.gradle.idea.IdeaPluginPlugin;
import org.xtext.gradle.idea.tasks.IdeaExtension;
import org.xtext.gradle.idea.tasks.RunIdea;

@SuppressWarnings("all")
public class IdeaAggregatorPlugin implements Plugin {
  public final static String AGGREGATE_SANDBOX_TASK_NAME = "aggregateSandbox";
  
  @Override
  public void apply(final Project project) {
    PluginContainer _plugins = project.getPlugins();
    _plugins.apply(IdeaDevelopmentPlugin.class);
    ExtensionContainer _extensions = project.getExtensions();
    final IdeaExtension idea = _extensions.getByType(IdeaExtension.class);
    TaskContainer _tasks = project.getTasks();
    Sync _create = _tasks.create(IdeaAggregatorPlugin.AGGREGATE_SANDBOX_TASK_NAME, Sync.class);
    final Procedure1 _function = new Procedure1() {
      @Override
      public void apply(final Sync it) {
        it.setDescription("Creates a folder containing the plugins to run Idea with");
        it.setGroup(BasePlugin.BUILD_GROUP);
      }
    };
    final Sync aggregateSandbox = ObjectExtensions.operator_doubleArrow(_create, _function);
    TaskContainer _tasks_1 = project.getTasks();
    RunIdea _create_1 = _tasks_1.create(IdeaComponentPlugin.RUN_IDEA_TASK_NAME, RunIdea.class);
    final Procedure1 _function_1 = new Procedure1() {
      @Override
      public void apply(final RunIdea it) {
        it.setDescription("Runs Intellij Idea with all aggregated plugins installed");
        it.setGroup(IdeaDevelopmentPlugin.IDEA_TASK_GROUP);
      }
    };
    final RunIdea runIdea = ObjectExtensions.operator_doubleArrow(_create_1, _function_1);
    final Action _function_2 = new Action() {
      @Override
      public void execute(final Project it) {
        File _sandboxDir = idea.getSandboxDir();
        aggregateSandbox.into(_sandboxDir);
        Set _subprojects = it.getSubprojects();
        final Function1 _function = new Function1() {
          @Override
          public Boolean apply(final Project it) {
            PluginContainer _plugins = it.getPlugins();
            return Boolean.valueOf(_plugins.hasPlugin(IdeaPluginPlugin.class));
          }
        };
        Iterable _filter = IterableExtensions.filter(_subprojects, _function);
        final Function1 _function_1 = new Function1() {
          @Override
          public Task apply(final Project it) {
            TaskContainer _tasks = it.getTasks();
            return _tasks.getAt(IdeaComponentPlugin.ASSEMBLE_SANDBOX_TASK_NAME);
          }
        };
        Iterable _map = IterableExtensions.map(_filter, _function_1);
        final Function1 _function_2 = new Function1() {
          @Override
          public TaskOutputs apply(final Task it) {
            return it.getOutputs();
          }
        };
        Iterable _map_1 = IterableExtensions.map(_map, _function_2);
        aggregateSandbox.from(_map_1);
        runIdea.dependsOn(aggregateSandbox);
        File _sandboxDir_1 = idea.getSandboxDir();
        runIdea.setSandboxDir(_sandboxDir_1);
        File _ideaHome = idea.getIdeaHome();
        runIdea.setIdeaHome(_ideaHome);
        FileCollection _ideaRunClasspath = idea.getIdeaRunClasspath();
        runIdea.setClasspath(_ideaRunClasspath);
      }
    };
    project.afterEvaluate(_function_2);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy