插件与IntelliJ平台产品的兼容性

原文链接:
http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html

所有基于IntelliJ平台的产品(IntelliJ IDEA、RubyMine、WebStorm、PhpStorm、PyCharm、AppCode等等)共享相同的底层API。因此,如果一个插件没有使用任何Java特定的功能,那么它可以被标记为兼容任何其他产品。这是通过在plugin.xml文件中指定模块依赖关系来完成的。

一个模块依赖就是一个 <depends> 标签,它的内容以 com.intellij.modules 开头。

<idea-plugin>
    <depends>com.intellij.modules.lang</depends>
</idea-plugin>

如果一个插件在其plugin.xml中不包含任何模块依赖项标签,则它将被假定为一个旧版插件,并且仅在IntelliJ IDEA中加载。

如果plugin.xml包含一个或多个这样的标签,那么只有在产品包含插件所依赖的所有模块时才会加载该插件。

以下模块目前适用于基于IntelliJ平台的所有产品:

  • com.intellij.modules.platform
  • com.intellij.modules.lang
  • com.intellij.modules.vcs
  • com.intellij.modules.xml
  • com.intellij.modules.xdebugger
  • 以下模块仅在特定产品中可用:

    com.intellij.modules.database IntelliJ IDEA Ultimate Edition, PhpStorm, RubyMine, PyCharm, DataGrip com.intellij.modules.python PyCharm com.intellij.modules.ruby RubyMine

    PhpStorm没有任何特定于自身的模块,但它包含PHP插件,你也可以使用它作为依赖:com.jetbrains.php

    你还可以指定可选的模块依赖关系。 如果你的插件可以与所有产品配合使用,但提供了一些特定的Java功能,你可以像这样使用依赖标记:

    <depends optional="true" config-file="my-java-features.xml"> 
        com.intellij.modules.java