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>() {
@Override
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.
Followup:
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?