How can I partition the plugin.xml into other xml files?

The plugin.xml is getting very large and disorganized. How can I split it into other modules or partition it into other xml files?

Here you go:

<?xml version="1.0" encoding="utf-8"?>
<idea-plugin xmlns:xi="http://www.w3.org/2001/XInclude">
    <xi:include href="plugin-featureX.xml"/>
    <xi:include href="plugin-featureY.xml"/>
    <xi:include href="plugin-featureZ.xml"/>

    <depends optional="true" config-file="plugin-optional-dependencyX.xml">dependencyXId</depends>
    <depends optional="true" config-file="plugin-optional-dependencyY.xml">dependencyYId</depends>
</idea-plugin>

Add the xmlns:xi to the idea-plugin root element, and then you can use xi:include to pull in other plugin*.xml files unconditionally, and of course you can use depends to pull in optional dependencies.

Note that, at least based on my experience, xi:include is only processed for the root plugin.xml, though depends can be added at any level.

Hope that helps!

2 Likes

As @illuminatedcloud said there are two ways:

  1. Use depends to declare dependencies (both optional and required), you can read more here:
    Plugin Configuration File | IntelliJ Platform Plugin SDK
  2. Use include directive with from XInclude namespace. I didn’t find better example than the following:
    Combining XML Documents with XInclude | Microsoft Learn

:bulb: Tip: if you dont want to add a new namespace you may use <depends> several time, including all of you files with the same dependency and make them required.

1 Like

This is discouraged practice and will be flagged by Plugin Verifier.

1 Like