How to correctly create the plugin menu in plugin.xml

Answered

Hi Jetbrains Comunity. I have the next issue. In plugin.xml we have a group item and according to the Intellij SDK specification, the id for the group should be unique. The main question is how to use the same custom group for two different plugins. I created an example. So, imagine that we have two plugins with the next plugin.xml:
First (I write only the actions tag)
<actions>
<group id="Plugin.Test" text="Plugins Test" popup="true">
<add-to-group group-id="MainMenu" anchor="after" relative-to-action="WindowMenu"/>
</group>

<action class="com.demo.plugin_1.Plugin1" text="Plugin 1">
<add-to-group group-id="Plugin.Test"/>
</action>
</actions>
Second
<actions>
<group id="Plugin.Test" text="Plugins Test" popup="true">
<add-to-group group-id="MainMenu" anchor="after" relative-to-action="WindowMenu"/>
</group>

<action class="com.demo.plugin_1.Plugin1" text="Plugin 1">
<add-to-group group-id="Plugin.Test"/>
</action>
</actions>
And I got the next exception:
2022-06-22 17:29:55,422 [ 127671] ERROR - nSystem.impl.ActionManagerImpl - ID "Plugin.Test" is already taken by action "Plugins Test (null)" (Plugin: Plugin_1). Action "null (null)" (Plugin: Plugin_2) cannot use the same ID [Plugin: com.demo.plugin_2]
com.intellij.diagnostic.PluginException: ID "Plugin.Test" is already taken by action "Plugins Test (null)" (Plugin: Plugin_1). Action "null (null)" (Plugin: Plugin_2) cannot use the same ID [Plugin: com.demo.plugin_2]
Please, can you help me with this issue? And also please explain the best practice on How to build the structure for the plugin menu.
P.S. I pin a log file with a full exception. Links on code with my example:
https://github.com/stasiukevych/plugin_1
https://github.com/stasiukevych/plugin_2

1 comment
Comment actions Permalink

Only one of the plugins can actually define the <group> with its unique ID. The other one canthen simply add additional actions to it by simply using <add-to-group>. Also, it is discouraged to add top-level menu entries, please find existing group in builtin menu, e.g. "Tools" if there's no better suitable alternative.

0

Please sign in to leave a comment.