A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html below:

Plugin Dependencies | IntelliJ Platform Plugin SDK

Plugin Dependencies

A plugin may depend on API and classes from other plugins, either bundled or third-party.

This document describes the syntax for declaring plugin dependencies and optional plugin dependencies. For more information about dependencies on the IntelliJ Platform modules, see Plugin Compatibility with IntelliJ Platform Products.

For adding dependencies on 3rd party libraries, use regular Gradle dependency management.

Required Steps

To express a dependency on classes from other plugins or modules, perform the following three required steps detailed below on this page:

  1. Locate Plugin ID

  2. Project Setup

  3. Declaration in plugin.xml

If java.lang.NoClassDefFoundError occurs at runtime, most likely Step 3 was omitted.

Otherwise, loading the plugin dependency may have failed, check log files from the Development Instance.

    1. Locating Plugin ID and Preparing Sandbox

    A compatible version must be chosen carefully according to the plugin's compatibility. For non-bundled plugins, it is not possible to specify the minimum/maximum version for the dependent plugin. (Issue)

    JetBrains Marketplace

    For plugins published on JetBrains Marketplace:

    1. Open plugin's detail page

    2. Scroll down to the bottom section Additional Information

    3. Copy Plugin ID

    Bundled and Other Plugins

    All IDs of bundled plugins can be gathered using a dedicated Gradle task. See Other tab on how to locate the plugin ID for a plugin distribution file.

    Use printBundledPlugins task.

    Use listBundledPlugins task.

    Locate the plugin's main JAR file containing the META-INF/plugin.xml descriptor with the <id> tag (use <name> if <id> is not specified).

    Bundled plugins are located in $PRODUCT_ROOT$/plugins/$PLUGIN_NAME$/lib/$PLUGIN_NAME$.jar.

    IDs of Bundled Plugins

    The following table lists some commonly used bundled plugins and their ID. See also Modules Specific to Functionality.

    Preparing Sandbox

    If the plugin is not bundled with the target IDE, run the (sandbox) IDE Development Instance of your target IDE and install the plugin there.

    2. Project Setup

    Depending on the chosen development workflow (Gradle or DevKit), one of the following steps is necessary.

    IntelliJ Platform Gradle Plugin (2.x)

    Define dependencies on plugins using the provided helper functions in the dependencies {} block of the build.gradle.kts file:

    dependencies { intellijPlatform { bundledPlugin("<pluginId>") plugin("<nonBundledPluginId>:<version>") } }

    For bundled plugins, use bundledPlugin(). Use plugin() for non-bundled plugins (for example, from JetBrains Marketplace).

    See Plugins for full reference and additional options.

    Gradle IntelliJ Plugin (1.x)

    Gradle IntelliJ Plugin (1.x) is no longer under active development.

    Whenever possible, use IntelliJ Platform Gradle Plugin (2.x) instead.

    See the intellij.plugins property for acceptable values.

    Add the dependency to the intellij.plugins parameter in your build script:

    intellij { plugins.set(listOf("com.example.another-plugin:1.0")) }

    intellij { plugins = ['com.example.another-plugin:1.0'] }

    Transitive dependencies required for tests must currently be specified explicitly.

    Plugin DevKit

    Existing DevKit-based projects can be converted to use Gradle setup where dependency management is fully automated.

    Add the JARs of the plugin on which the project depends to the Classpath of the IntelliJ Platform SDK.

    Do not add the plugin JARs as a library: this will fail at runtime because the IntelliJ Platform will load two separate copies of the dependency plugin classes.

    Adding a plugin dependency in a DevKit-based plugin
    1. Open the Project Structure dialog and go to the section.

    2. Select the SDK used in the project.

    3. Click the + button in the Classpath tab.

    4. Select the plugin JAR depending on whether it is a bundled or non-bundled plugin:

      3. Dependency Declaration in plugin.xml

      Regardless of whether a plugin project uses Modules Available in All Products or Modules Specific to Functionality, the correct module must be listed as a dependency in plugin.xml. If a project depends on another plugin, the dependency must be declared like a module. If only general IntelliJ Platform features (APIs) are used, then a default dependency on com.intellij.modules.platform must be declared.

      To display a list of available IntelliJ Platform modules, invoke the code completion feature for the <depends> element contents while editing the plugin project's plugin.xml file.

      In the plugin.xml, add a <depends> tag with the dependency plugin's ID as its content. Continuing with the example from the Project Setup above, the dependency declaration in plugin.xml would be:

      <depends>com.example.another-plugin</depends>

      Optional Plugin Dependencies

      A plugin can also specify an optional plugin dependency. In this case, the plugin will load even if the plugin it depends on is not installed or enabled, but part of the plugin's functionality will not be available.

      Declare additional optional="true" and required config-file attribute pointing to the optional plugin descriptor file:

      <depends optional="true" config-file="myPluginId-optionalPluginName.xml">dependency.plugin.id</depends>

      Additional plugin descriptor files must follow the naming pattern myPluginId-$NAME$.xml resulting in unique filenames to prevent problems with classloaders in tests (Details).

      Sample

      The plugin adds additional highlighting for Java and Kotlin files. The main plugin.xml defines a required dependency on the Java plugin (plugin ID com.intellij.java) and registers the corresponding com.intellij.annotator extension. Additionally, it specifies an optional dependency on the Kotlin plugin (plugin ID org.jetbrains.kotlin):

      plugin.xml

      <idea-plugin> ... <depends>com.intellij.java</depends> <depends optional="true" config-file="myPluginId-withKotlin.xml">org.jetbrains.kotlin</depends> <extensions defaultExtensionNs="com.intellij"> <annotator language="JAVA" implementationClass="com.example.MyJavaAnnotator"/> </extensions> </idea-plugin>

      The configuration file myPluginId-withKotlin.xml is located in the same directory as the main plugin.xml file. In that file, the annotator extension for Kotlin is defined:

      myPluginId-withKotlin.xml

      <idea-plugin> <extensions defaultExtensionNs="com.intellij"> <annotator language="kotlin" implementationClass="com.example.MyKotlinAnnotator"/> </extensions> </idea-plugin>

      12 May 2025


      RetroSearch is an open source project built by @garambo | Open a GitHub Issue

      Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

      HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4