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?

0
11 comments
Avatar
Permanently deleted user

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

0
Avatar
Permanently deleted user

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.

0
Avatar
Permanently deleted user

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.

0
Avatar
Permanently deleted user

You may only use the
interface-class once because it's used as a key for
ComponentManager.getComponent(Class).


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.

0
Avatar
Permanently deleted user

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

0
Avatar
Permanently deleted user

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... :)

0
Avatar
Permanently deleted user

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.

Yes, it isn't documented anywhere but it works that way :) Component is used only for specified module types.

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.

This is plugin.xml from DevKit and it works, because DevKit works :)

0
Avatar
Permanently deleted user

Thanks for reply. I'm quite newbie to plugin development and wanted someone to confirm my thoughts.

0
Avatar
Permanently deleted user

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

0
Avatar
Permanently deleted user

Grrr, that stuff isn't documented anywhere, otherwise it would have been implemented correctly right from the start :(

Sascha

0

Please sign in to leave a comment.