Backend Development 15 min read

Step-by-Step Guide to Developing an IntelliJ IDEA Plugin

This tutorial explains how to set up the development environment, create a plugin project using DevKit or Gradle, configure plugin.xml and build.gradle, implement a Hello World action, package, install, and manage the plugin, as well as handle components, UI extensions, and data persistence in IntelliJ IDEA.

58 Tech
58 Tech
58 Tech
Step-by-Step Guide to Developing an IntelliJ IDEA Plugin

The article begins with a preface describing the need for static code analysis in CI pipelines and introduces the 58EE plugin, which manages rule sets for different business lines and supports both Eclipse and IDEA on macOS and Windows.

Environment Setup

1. Configure JDK : Open File → Project Structure , go to SDKs , add a JDK and select its installation path.

2. Configure Plugin Development SDK : In the same panel, add IntelliJ Platform Plugin SDK and point to the IDEA installation directory.

3. Enable Plugin DevKit : Ensure the Plugin DevKit plugin is enabled in Settings → Plugins .

Creating the Plugin Project

Two project types are available:

DevKit project : Simple structure, quick start.

Gradle project : Better dependency management; select Gradle , enable Java and IntelliJ Platform Plugin modules.

Both project types generate a plugin.xml under resources/META-INF and, for Gradle, a build.gradle file that works like a Maven pom.xml for declaring dependencies.

Demo: Hello World Action

Add an action entry in plugin.xml with attributes class , id , text , add-to-group , and anchor . Implement the action class by extending com.intellij.openapi.actionSystem.AnAction and overriding actionPerformed() . Run the plugin via a Plugin run configuration; a new IDEA instance will load the plugin, showing a new menu item that displays a Hello World dialog.

Packaging the Plugin

DevKit packaging : Use Build → Prepare Plugin Module ‘xxx’ For Deployment to create a zip file.

Gradle packaging : Execute clean then build in the Gradle tool window; the zip appears in build/distributions .

Installation

Plugins can be installed locally by copying the zip to IDEA’s plugins directory or via Settings → Plugins → Install plugin from disk . Online installation uses the JetBrains marketplace or a custom repository defined by an XML file containing plugin entries with id , url , and version attributes.

Plugin Components

Three component types exist: Application, Project, and Module components, declared with <application-components> , <project-components> , and <module-components> in plugin.xml . Their lifecycle methods include initComponent() , disposeComponent() , projectOpened() , projectClosed() , and moduleAdded() .

Extending the UI

Use extensions (e.g., com.intellij.applicationConfigurable ) to add settings panels. Implement Configurable with methods createComponent() , isModified() , apply() , reset() , and disposeUIResources() . The UI is built with Swing components returned as JComponent instances.

Data Persistence

Two mechanisms are provided:

PropertiesComponent : Simple key‑value storage via setValue() and getValue() .

PersistentStateComponent : Annotate a class with @State(name = "myComponent", storages = @Storage("myComponent.xml")) ; implement getState() and loadState() to read/write an XML file.

The article concludes by noting many additional topics (e.g., progress bars, PSI) remain to be covered.

JavaGradleIntelliJ IDEAplugin developmentIDE extensionsDevKit
58 Tech
Written by

58 Tech

Official tech channel of 58, a platform for tech innovation, sharing, and communication.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.