IntelliJ Platform Plugin SDK Help

IntelliJ Platform Gradle Plugin 2.x (Beta)

The IntelliJ Platform Gradle Plugin 2.x is a plugin for the Gradle build system to help configure environments for building, testing, verifying, and publishing plugins for IntelliJ-based IDEs. It is a successor of Gradle IntelliJ Plugin (1.x).

Requirements

IntelliJ Platform Gradle Plugin 2.x requires the following minimal versions:

  • IntelliJ Platform: 2022.3

  • Gradle: 8.2

    See the Gradle Installation guide on how to upgrade.

  • Java Runtime: 17

    See Gradle JVM in Settings | Build, Execution, Deployment | Build Tools | Gradle.

Usage

To apply the IntelliJ Platform Gradle Plugin to a project, add the following entry to the plugins block in the build.gradle.kts file:

plugins { id("org.jetbrains.intellij.platform") version "2.0.0-beta1" }

If migrating from the Gradle IntelliJ Plugin 1.x, replace the old org.jetbrains.intellij identifier to org.jetbrains.intellij.platform and apply its latest 2.0.0-beta1 version.

Snapshot Release

To use the latest snapshot versions, add the following to the settings.gradle.kts file:

pluginManagement { repositories { maven("https://oss.sonatype.org/content/repositories/snapshots/") gradlePluginPortal() } }

Plugins

The IntelliJ Platform Gradle Plugin consists of multiple plugins which can be applied in bundles (Platform or Module) or separately.

Subplugins architecture allows applying a subset of features, e.g., to provide the IntelliJ Platform dependency to a project submodule without creating unnecessary tasks.

Configuration

Setting Up Repositories

All IntelliJ Platform SDK artifacts are available via IntelliJ Maven repositories (see IntelliJ Platform Artifacts Repositories), which exist in three variants:

  • releases

  • snapshots

  • nightly (only selected artifacts)

Example:

Setup Maven Central and defaultRepositories() repositories:

repositories { mavenCentral() intellijPlatform { defaultRepositories() } }

Example #2:

Build a plugin against a release version of the IntelliJ Platform with dependency on a plugin from the JetBrains Marketplace:

repositories { mavenCentral() intellijPlatform { releases() marketplace() } }

See Repositories Extension on how to configure additional repositories.

Dependency Resolution Management

To access the IntelliJ Platform Gradle Plugin within the settings.gradle.kts to use with dependencyResolutionManagement, add:

import org.jetbrains.intellij.platform.gradle.extensions.intellijPlatform plugins { id("org.jetbrains.intellij.platform.settings") version "2.0.0-beta1" } dependencyResolutionManagement { repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS repositories { mavenCentral() intellijPlatform { defaultRepositories() } } }

Cache Redirector

Some repositories, by default, point to JetBrains Cache Redirector to provide better resource resolution. However, it is possible to use the direct repository URL, if available.

To switch off the default usage of JetBrains Cache Redirector, see the useCacheRedirector build feature.

Setting Up IntelliJ Platform

Dependencies and repositories are handled using explicit entries within dependencies {} and repositories {} blocks in build.gradle.kts file.

A minimum configuration for targeting IntelliJ IDEA Community 2023.3:

repositories { mavenCentral() intellijPlatform { defaultRepositories() } } dependencies { intellijPlatform { intellijIdeaCommunity("2023.3") } }

The intellijIdeaCommunity in the previous sample is one of the extension functions available for adding IntelliJ Platform dependencies to the project. See Dependencies Extension on how to target other IDEs.

Parametrize IntelliJ Platform Dependency

As a fallback, intellijPlatform extension can be used to allow dynamic configuration of the target platform, e.g., via gradle.properties:

platformType = IC platformVersion = 2023.3

The above Gradle properties can be referenced in the build.gradle.kts file with:

dependencies { intellijPlatform { val type = providers.gradleProperty("platformType") val version = providers.gradleProperty("platformVersion") create(type, version) } }

The intellijPlatform helper accepts also the IntelliJPlatformType type:

import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType dependencies { intellijPlatform { val version = providers.gradleProperty("platformVersion") create(IntelliJPlatformType.IntellijIdeaUltimate, version) } }

Local IntelliJ Platform IDE Instance

It is possible to refer to the locally available IntelliJ-based IDE using the local helper function:

repositories { intellijPlatform { localPlatformArtifacts() } } dependencies { intellijPlatform { local("/Users/user/Applications/IntelliJ IDEA Ultimate.app") } }

Setting Up Plugin Dependencies

To specify a dependency on a plugin, it is important to distinguish bundled plugins from plugins available in JetBrains Marketplace.

The Dependencies Extension provides a set of helpers to manage plugin dependencies:

repositories { intellijPlatform { defaultRepositories() } } dependencies { intellijPlatform { intellijIdeaCommunity("2024.1") bundledPlugin("com.intellij.java") plugin("org.intellij.scala", "2024.1.4") } }
Last modified: 18 April 2024