intellij-sdk-code-samples/topics/tools_intellij_platform_gradle_plugin.md
2024-01-25 17:43:55 +01:00

6.0 KiB

IntelliJ Platform Gradle Plugin 2.x (EA)

IntelliJ Platform Gradle Plugin user and migration guide.

Current Release: Early Access

GitHub: Releases & Changelog, Issue Tracker

Slack: #intellij-platform-gradle-plugin on the JetBrains Platform Slack

The IntelliJ Platform Gradle Plugin 2.x is a plugin for the Gradle build system to help configure your environment for building, testing, verifying, and publishing plugins for IntelliJ-based IDEs.

It is going to replace the current (1.x) in the future.

This plugin is currently in Early Access and may not support all features and project setups yet (see also ). Please report bugs or problems in the above-linked issue tracker or Slack channel.

Any documentation issues on this page should be reported using the feedback form on the bottom of this page.

Thanks a lot in advance for your feedback!

{title="Early Access Status" style="warning"}

Requirements

The following platforms and environments are supported:

  • IntelliJ Platform: 2022.3 and later
  • Java Runtime: 17 and later
  • Gradle: 8.0 and later

Usage

To use the current Early Access snapshot versions, add to your settings.gradle.kts file:

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

In the build.gradle.kts file, replace the existing reference to the plugin (org.jetbrains.intellij) with:

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

Available Subplugins

The plugin has a new ID: org.jetbrains.intellij.platform, but also was split into subplugins. This approach allows you to choose between applying all configurations and tasks at once, or applying them separately, e.g., to only use an IntelliJ SDK dependency without creating any tasks.

org.jetbrains.intellij.platform

{id="plugin.platform"}

This plugin applies all project-level plugins, which brings the fully-flagged tooling for plugin development for IntelliJ-based IDEs.

It includes and subplugins.

org.jetbrains.intellij.platform.base

{id="plugin.base"}

Base plugin registers all necessary custom configurations and dependencies transformers used for handling IntelliJ SDK, JetBrains Runtime, or other plugins when used as dependencies.

org.jetbrains.intellij.platform.tasks

{id="plugin.tasks"}

Tasks plugin registers and preconfigures all tasks introduced by the IntelliJ Platform Gradle Plugin. It can be omitted when referring to any IntelliJ SDK dependencies without invoking tasks on project submodules.

org.jetbrains.intellij.platform.settings

{id="plugin.settings"}

Settings plugin is required in settings.gradle.kts when using RepositoryHandler extensions when declaring the IntelliJ Maven repository (see ) for the dependencyResolutionManagement Gradle mechanism.

Configuration

Auto-completion, Quick Documentation, and other code insight features are available for many extension functions and properties.

{title="Exploring Configuration Options"}

Setting up IntelliJ Repositories

{id="intellij.repositories"}

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

  • releases
  • snapshots
  • nightly (only select artifacts)

All required repositories for the project must be declared explicitly within the intellijPlatform extension:

repositories {
  mavenCentral()

  intellijPlatform {
    releases()
    snapshots()
    nightly()
  }
}

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 {
    releases()
  }
}


dependencies {
  intellijPlatform {
    intellijIdeaCommunity("2023.3")
  }
}

The intellijIdeaCommunity in the previous sample is one of extension functions available for adding IntelliJ SDK dependencies to the project. Other IDEs can be targeted using one the extensions listed in the table below.

Extension Target IDE
androidStudio Android Studio
clion CLion
gateway Gateway
goland GoLand
intellijIdeaCommunity IntelliJ IDEA Community Edition
intellijIdeaUltimate
phpstorm PhpStorm
pycharmCommunity PyCharm Community Edition
pycharmProfessional PyCharm Professional
rider Rider

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

Tasks

TODO

Migration FAQ

Unresolved 'idea' plugin

Add an explicit dependency on the plugin in build.gradle.kts:

id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.7"