Several components with same interface for different module types
So, I have:
com.intellij.javaee.make.ModuleBuildProperties
com.mycompany.myplugin.AModuleBuildProperties
com.intellij.javaee.make.ModuleBuildProperties
com.mycompany.myplugin.AModuleBuildProperties
]]>
DevKit shows error "Multiple components with the same interface are not allowed".
Is it true and I really cannot use such configuration (actually it seems to be working) and this is DevKit bug? Or I should do some dirty magic (like introducing additional interfaces) to make it work?
Please sign in to leave a comment.
Yes, this is true: You may only use the interface-class once because it's used as a key for ComponentManager.getComponent(Class). See also http://www.jetbrains.com/idea/plugins/plugin_structure.html under "Plugin Components".
You should probably just remove the interface-class tags and it will work correctly - you'll probably need to change the second use of AModuleBuildProperties to BModuleBuildProperties though ;)
Sascha
If I remove interface-class then my class is not used as ModuleBuildProperties (DefaultBuildProvider cannot find it for building of the module).
P.S. Of course there is B. This is just an example.
Quote from DevKit plugin.xml:
com.intellij.javaee.make.ModuleBuildProperties org.jetbrains.idea.devkit.build.PluginModuleBuildProperties ]]>
I want the same thing, but for several module types.
Yes. But. This is a module component. And each module type has only one instance of this component. So I don't break the rule of one-class-per-interface-in-component-manager.
Does that mean that a module-component is only instantiated for modules that match the "type"-Attribute? That would make sense, but AFAIK this isn't documented anywhere.
Does your example that is flagged by the DevKit actually work as expected? In that case the highlighting is probably wrong and a DevKit bug.
I'm not really familiar with ModuleComponents, sorry :(
Sascha
In your case it's fine to use the same interface class multiple times, as it is only used once per module. (By the way: Look at the WebLogic integration plugin. There a similar construct is used.) You just have to ignore the DevKit error message... :)
Yes, it isn't documented anywhere but it works that way :) Component is used only for specified module types.
This is plugin.xml from DevKit and it works, because DevKit works :)
Thanks for reply. I'm quite newbie to plugin development and wanted someone to confirm my thoughts.
Sascha,
I think it's really a DevKit bug, as the error checking isn't aware of the module type contract. Maybe someone should file a JIRA request some day. Until now I preferred to simply ignore the error... :)
Martin
Filed: http://www.jetbrains.net/jira/browse/IDEA-10478
Grrr, that stuff isn't documented anywhere, otherwise it would have been implemented correctly right from the start :(
Sascha