Plugin detection and configuration

I want to be able to add or update Eclipse and/or Idea plugin configuration when my plugin is being applied. What is the best way to approach this.

I have tried this:

PluginCollection<EclipseWtpPlugin> eclipsePlugins = plugins.withType(EclipseWtpPlugin.class);
          if(!eclipsePlugins.isEmpty()) {
            System.out.println("eclipse plugin added.");

this (works to find Eclipse plugin):

PluginCollection<IdeaPlugin> ideaPlugins = plugins.withType(IdeaPlugin.class);
          ideaPlugins.whenPluginAdded(new Action<IdeaPlugin>() {
            public void execute(IdeaPlugin ideaPlugin) {
                System.out.println("has idea");
                //To change body of implemented methods use File | Settings | File Templates.

and this (works to find Idea plugin):

private void configureIdeaIfPresent(PluginContainer plugins) {
                  if(plugins.hasPlugin("idea")) {
            System.out.println("has idea");

With differing results between Eclipse and IntelliJ as far as detecting the existence of the plugins. Any direction on a best practice or insight from experience is welcome.


After testing different options the project.getPlugins().getPlugin([plugintype]) appears to do what I want if my plugin is applied to the project after the other plugins. This is fine for what I am trying to achieve but if there is a way to do this without having to depend on when they are applied that would be preferred. Is this possible? I like the whenPluginApplied method, is this suppose to be tied into the entire configuration lifecycle?

Hello Jason,

to react on applied IDE plugins from your plugin code, you can simply use

apply(Project project){
    project.plugins.withType(IdeaPlugin) {

The withType method is lazy evaluated. this means it doesn’t matter if the idea plugin is applied after or before your plugin is applied.

hope that helps!


This does work. The one difference I am seeing is the withType method returns a collection and the getPlugin(SomePlugin.class) returns a single instance. I am thinking I would prefer the getPlugin method. Any disadvantages or advantages with either way of doing it?