IntelliJ Platform Plugin Template

repository·main·Indexed 25 days ago

https://github.com/jetbrains/intellij-platform-plugin-template

A preconfigured scaffold for accelerating the development of IntelliJ Platform plugins. It provides a ready-to-use Gradle setup, CI/CD workflows via GitHub Actions for signing and publishing to the JetBrains Marketplace, and best practices for plugin structure. The template includes sample implementations for ProjectActivity and ToolWindowFactory, supports both Kotlin and Java, and integrates the gradle-changelog-plugin for automated versioning.

Tokens
3.2K
Snippets
6
Records
19
Agent score
37%

What's inside intellij-platform-plugin-template

  1. Understand the template's sample code structure

    main

    The template includes minimal sample files in src/main/kotlin to demonstrate core plugin concepts. If you use Java, move these to src/main/java.

    Sample Files:

    • startup/MyProjectActivity.kt: Project startup activity.
    • services/MyProjectService.kt: Project-level service.
    • toolWindow/MyToolWindowFactory.kt: Tool window factory for creating tool window content.
    • MyBundle.kt: Bundle class for accessing resource messages.

    Note: Remove all non-needed sample code files and their corresponding entries in plugin.xml before finalizing your plugin.

  2. Understand the plugin project structure

    main

    A project generated from this template follows this directory layout:

    • .github/: GitHub Actions workflows and Dependabot configuration.
    • .run/: Predefined Run/Debug Configurations for the IDE.
    • gradle/wrapper/: Gradle Wrapper files.
    • src/main/kotlin/: Kotlin production source code.
    • src/main/resources/: Plugin resources (e.g., plugin.xml, icons, messages).
    • src/main/java/: (Manually created) Java production source code.
    • src/test/kotlin/: Kotlin test source code.
    • src/test/testData/: Test data used by tests.
    • build.gradle.kts: Main Gradle configuration.
    • settings.gradle.kts: Gradle project settings and repository management.
    • gradle.properties: Project-specific configuration properties.
    • CHANGELOG.md: Full change history.
  3. Manage Project Dependencies

    main

    Dependency management is distributed across three files:

    • settings.gradle.kts: Declares Gradle plugin versions and repositories.
    • build.gradle.kts: Declares the target IntelliJ Platform version and project dependencies.
    • gradle.properties: Stores repository-specific metadata used by build and CI.

    To add a standard library dependency, use the dependencies block in build.gradle.kts. For IntelliJ Platform specific dependencies, use the intellijPlatform { ... } extension.

    dependencies {
      implementation("group:artifact:version")
    }
  4. Sign and Publish Plugins to JetBrains Marketplace

    main

    The template automates publishing via GitHub Actions.

    Prerequisites

    1. Manual Setup: You must manually create a new plugin in the JetBrains Marketplace first to configure license and repository settings.
    2. Authentication: Add your Marketplace token as a GitHub Secret named PUBLISH_TOKEN. You can obtain this token from your Marketplace profile dashboard under the 'My Tokens' tab.
    3. Signing: The template uses standard environment variables for plugin signing (consumed by the IntelliJ Platform Gradle Plugin) to avoid checking secrets into VCS.

    Release Flow

    1. A push or PR to main triggers the Build workflow, which runs tests and creates a Draft Release on GitHub.
    2. Review the Draft Release. When ready, click Publish release.
    3. This triggers the Release workflow, which signs the plugin, updates the changelog, and publishes the plugin to the JetBrains Marketplace.
  5. Run functional tests

    main

    Functional tests in this template run in a headless environment using an actual IDE instance. They typically test features as a whole rather than individual functions.

    • Location: src/test/kotlin (e.g., MyPluginTest using BasePlatformTestCase).
    • How to run: Use the predefined Run Tests configuration in your IDE or execute the following command:
    ./gradlew check
  6. Maintain the Changelog using Keep a Changelog

    main

    The template uses the [Keep a Changelog] approach. The gradle-changelog-plugin automatically propagates entries from CHANGELOG.md to the IntelliJ Platform Gradle Plugin.

    To add changes, write them under the [Unreleased] section in CHANGELOG.md using appropriate groups like ### Added or ### Fixed.

    Example structure:

    # YourPlugin Changelog
    
    ## [Unreleased]
    ### Added
    - Initial scaffold created from IntelliJ Platform Plugin Template

    When a release is published via CI, the [Unreleased] header is automatically bumped to the new version, and a new empty [Unreleased] section is created for you.

    # YourPlugin Changelog
    
    ## [Unreleased]
    ### Added
    - Initial scaffold created from [IntelliJ Platform Plugin Template](https://github.com/JetBrains/intellij-platform-plugin-template)
  7. Create a new project from the template

    main

    To start a new IntelliJ Platform plugin project, use the GitHub template feature:

    1. Click the Use this template button on the repository page.
    2. Once the new repository is created, the Template Cleanup workflow will automatically run to remove template-specific metadata (like the original plugin name).
    3. In your new repository, navigate to Settings | Actions | General and enable Allow GitHub Actions to create and approve pull requests.
    4. Clone the repository to your local machine and open it in IntelliJ IDEA.
    5. Set the Project SDK to Java 21 in the Project Structure settings.
    6. Review and update gradle.properties and plugin.xml with your specific plugin metadata.

    Note: If you want to use Java instead of Kotlin, you must manually create the src/main/java directory.

  8. Configure plugin metadata in gradle.properties

    main

    The gradle.properties file contains project-specific configuration values that vary between different plugin implementations. Update these keys to define your project's identity and versioning:

    Property nameDescription
    groupProject group and default base package for sample sources
    versionCurrent plugin version in SemVer format
    pluginRepositoryUrlRepository URL used for generating URLs by the Gradle Changelog Plugin
    kotlin.stdlib.default.dependencySet to false to opt-out of bundling the Kotlin standard library
    org.gradle.configuration-cacheSet to true to enable Gradle Configuration Cache
    org.gradle.cachingSet to true to enable Gradle Build Cache