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

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

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

import com.google.common.base.Objects;
import java.io.File;
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.artifacts.Configuration;
import org.gradle.api.artifacts.ConfigurationContainer;
import org.gradle.api.file.CopySpec;
import org.gradle.api.file.FileCollection;
import org.gradle.api.plugins.BasePlugin;
import org.gradle.api.plugins.Convention;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.PluginContainer;
import org.gradle.api.specs.Spec;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.SourceSetOutput;
import org.gradle.api.tasks.TaskContainer;
import org.gradle.api.tasks.bundling.Zip;
import org.xtext.gradle.idea.IdeaComponentPlugin;
import org.xtext.gradle.idea.tasks.AssembleSandbox;

@SuppressWarnings("all")
public class IdeaPluginPlugin implements Plugin {
  public final static String IDEA_ZIP_TASK_NAME = "ideaZip";
  
  @Override
  public void apply(final Project project) {
    PluginContainer _plugins = project.getPlugins();
    _plugins.apply(IdeaComponentPlugin.class);
    Convention _convention = project.getConvention();
    final JavaPluginConvention java = _convention.getPlugin(JavaPluginConvention.class);
    SourceSetContainer _sourceSets = java.getSourceSets();
    final SourceSet mainSourceSet = _sourceSets.getByName("main");
    ConfigurationContainer _configurations = project.getConfigurations();
    final Configuration providedDependencies = _configurations.getAt(IdeaComponentPlugin.IDEA_PROVIDED_CONFIGURATION_NAME);
    ConfigurationContainer _configurations_1 = project.getConfigurations();
    final Configuration runtimeDependencies = _configurations_1.getAt(JavaPlugin.RUNTIME_CONFIGURATION_NAME);
    TaskContainer _tasks = project.getTasks();
    Task _at = _tasks.getAt(IdeaComponentPlugin.ASSEMBLE_SANDBOX_TASK_NAME);
    final AssembleSandbox assembleSandbox = ((AssembleSandbox) _at);
    final Procedure1 _function = new Procedure1() {
      @Override
      public void apply(final AssembleSandbox it) {
        CopySpec _classes = it.getClasses();
        SourceSetOutput _output = mainSourceSet.getOutput();
        _classes.from(_output);
        CopySpec _libraries = it.getLibraries();
        final Spec _function = new Spec() {
          @Override
          public boolean isSatisfiedBy(final File candidate) {
            final Function1 _function = new Function1() {
              @Override
              public Boolean apply(final File it) {
                String _name = candidate.getName();
                String _name_1 = it.getName();
                return Boolean.valueOf(Objects.equal(_name, _name_1));
              }
            };
            boolean _exists = IterableExtensions.exists(providedDependencies, _function);
            return (!_exists);
          }
        };
        FileCollection _filter = runtimeDependencies.filter(_function);
        _libraries.from(_filter);
        CopySpec _metaInf = it.getMetaInf();
        _metaInf.from("META-INF");
      }
    };
    ObjectExtensions.operator_doubleArrow(assembleSandbox, _function);
    TaskContainer _tasks_1 = project.getTasks();
    final Action _function_1 = new Action() {
      @Override
      public void execute(final Zip it) {
        it.setDescription("Creates an installable archive of this plugin");
        it.setGroup(BasePlugin.BUILD_GROUP);
        CopySpec _plugin = assembleSandbox.getPlugin();
        it.with(_plugin);
      }
    };
    final Zip ideaZip = _tasks_1.create(IdeaPluginPlugin.IDEA_ZIP_TASK_NAME, Zip.class, _function_1);
    TaskContainer _tasks_2 = project.getTasks();
    Task _at_1 = _tasks_2.getAt(BasePlugin.ASSEMBLE_TASK_NAME);
    _at_1.dependsOn(ideaZip);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy