Posted in

IntelliJ 平台 Gradle 插件 2.0 发布_AI阅读总结 — 包阅AI

包阅导读总结

1. 关键词:IntelliJ Platform、Gradle Plugin 2.0、更新、配置更改、功能改进

2. 总结:IntelliJ Platform Gradle Plugin 2.0 已发布,介绍了从创建到 2.0 版本的历程,包括新的策略如仓库和依赖管理,强大的 DSL,改进的测试体验,多项目构建支持,新名称及要求,强调了更新的重要性和下一步操作。

3. 主要内容:

– 新版本发布:IntelliJ Platform Gradle Plugin 2.0 可用,此前叫 Gradle IntelliJ Plugin

– 发展历程:

– 2015 年项目开始,初用 Groovy,2021 年 1.0 版用 Kotlin

– 2023 年夏开始调整核心功能,历经挑战发布 2.0

– 新特性与改进:

– 新的仓库和依赖管理策略,解决 1.x 版本架构问题

– 强大的 DSL 用于详细配置,包括插件配置、签名、验证和发布

– 测试体验改善,可针对不同平台和插件版本创建任务

– 支持多项目构建,通过子插件解决以往问题

– 新名称和要求:

– 新 ID 为 org.jetbrains.intellij.platform

– 限制对旧版 IntelliJ Platform、Gradle 和 Java Runtime 的支持

– 更新重要性:IntelliJ IDEA 2024.2 变化需迁移,Android Studio 2024.1 变化 1.x 无法处理,1.x 开发冻结

– 下一步:访问文档页面,查看项目模板的相关内容,有问题提交至 GitHub

思维导图:

文章地址:https://blog.jetbrains.com/platform/2024/07/intellij-platform-gradle-plugin-2-0/

文章来源:blog.jetbrains.com

作者:Jakub Chrzanowski

发布时间:2024/7/30 17:26

语言:英文

总字数:1340字

预计阅读时间:6分钟

评分:88分

标签:IntelliJ 平台,Gradle 插件,插件开发,Kotlin,依赖管理


以下为原文内容

本内容来源于用户推荐转载,旨在分享知识与观点,如有侵权请联系删除 联系邮箱 media@ilingban.com

IntelliJIntelliJ IDEANewsPlugins

IntelliJ Platform Gradle Plugin 2.0 Is Out!

Version 2.0 of the IntelliJ Platform Gradle Plugin is now available! Previously called the Gradle IntelliJ Plugin, this updated plugin for the Gradle build system simplifies the configuration of environments for building, testing, verifying, and publishing plugins for IntelliJ-based IDEs. Redesigned and rewritten, it addresses community-reported issues and feature requests from previous versions.

The path to 2.0

The project to create this plugin began in 2015 with the goal of simplifying the development and testing of plugins for JetBrains IDEs. Initially, it was developed in Groovy, which remained the primary language for the first six years, during the 0.x releases.

In May 2021, version 1.0 was released, marking a complete migration to Kotlin. This transition addressed multiple issues thanks to Kotlin’s strong typing and null safety, though the core architecture remained unchanged. Around the same time, Gradle announced the configuration and build cache mechanisms. Those improvements in the Gradle build system highlighted fundamental weaknesses in the Gradle IntelliJ Plugin, revealing that maintaining it without workarounds was no longer viable.

In the summer of 2023, we started adjusting the core functionality – the beginning of a challenging, year-long journey towards the release of version 2.0.

New strategy for repository and dependency management

One of our main goals was fixing an architectural problem in the 1.x versions, which applied repositories and dependencies implicitly during task runtime. This approach had numerous side effects, addressed in the new 2.0 release.

Repositories defined explicitly

The old version tried to keep configuration simple by adding all necessary repositories when the IntelliJ Platform dependency was resolved. The fixed repository list made Gradle search for dependencies in locations irrelevant to project needs or even unavailable for resolving.

repositories {    mavenCentral()    intellijPlatform {        // use the recommended repository list        defaultRepositories()        // or explicit set        jetbrainsIdeInstallers()        releases()        localPlatformArtifacts()        intellijDependencies()        // ...    }    maven("...") {       authentication {           // ...       }    }}

The current solution allows using a recommended set of repositories or using only specific elements whenever you don’t need others or decide to replace them with a custom artifactory.

All resources as dependencies

The solution present in 1.x requested dependencies and tools in the task execution phase – this prevented Gradle from caching the project configuration or task output. This could also result in unsatisfied requests when working in environments with limited network capacity.

With the 2.x release, everything required for building, testing, and verifying the plugin is defined as a dependency.

The new approach requires explicit declarations of the IntelliJ Platform and all other dependencies:

dependencies {   testImplementation(libs.junit)   intellijPlatform {       intellijIdeaCommunity("2023.2.7")       instrumentationTools()       pluginVerifier()       testFramework(TestFrameworkType.Platform)   }}

Relying fully on the Gradle approach for managing dependencies makes it possible to involve caching for every requested resource and avoid resolving dependencies eagerly.

Advanced dependency management

Changes applied to repository and dependency configuration allow involving advanced Gradle techniques, like declaring centralized repositories. All of the project repositories can now be specified within the settings.gradle.kts file, which applies them to all declared project modules.

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

From now on, the repositories {} block in any build.gradle.kts is redundant.

Powerful DSL

The new intellijPlatform {} extension replaces the old intellij {} and facilitates the detailed configuration of all relevant plugin configuration values, as well as signing, verifying, and publishing plugins:

intellijPlatform {   pluginConfiguration {       version = providers.gradleProperty("pluginVersion")       name = "My Awesome Plugin"       description = ...       changeNotes = ...       ideaVersion {           sinceBuild = "223"           untilBuild = "242.*"       }   }   signing {       // ...   }   publishing {       // ...   }   pluginVerification {       // ...   }}

All extension properties and helper methods accept values passed either eagerly or lazily wrapped with Provider, which is available in the Gradle API. However, the simple property assignment in the Kotlin DSL, introduced in Gradle 8.2, keeps this change transparent.

In addition to the root intellijPlatform {} extension, new extensions have been introduced for the repositories {} and dependencies {} blocks. Each of these extensions provides dedicated helpers for applying repositories and dependencies related to the development of plugins for the IntelliJ Platform. This approach offers full control over what is applied to the configuration.

Improved testing experience

The changes in how the IntelliJ Platform and dependencies in bundled and external plugins are applied to the project have opened up new possibilities in testing. You can now create custom run and test tasks targeting different IntelliJ Platform types and versions or plugin sets without changing the IntelliJ Platform version and type used to build the plugin.

Using the new intellijPlatformTesting {} extension, you can register tasks of various types and purposes:

val runPhpStorm by intellijPlatformTesting.runIde.registering {   type = IntelliJPlatformType.PhpStorm   version = "2024.2"   plugins {       plugin("pluginId", "1.0.0")       disablePlugin("bundledPluginId")   }}

The code above creates a new runPhpStorm task for running PhpStorm 2024.2 locally for manual testing purposes with the pluginId installed from JetBrains Marketplace and the bundledPluginId plugin disabled.

This approach helps with running manual or automated tests for different scenarios, such as ones where bundled plugins are disabled or optional plugins are installed.

Multi-project builds support

To address previous issues with multi-project builds, the IntelliJ Platform Gradle Plugin has been restructured into several sub-plugins. These sub-plugins can be applied selectively based on the architecture of your project.

This modular approach allows for the application of specific features, such as providing IntelliJ Platform dependencies to a project submodule, without introducing unnecessary tasks.

For projects using IntelliJ-based IDEs, the main module should always include the org.jetbrains.intellij.platform plugin in its configuration file. In contrast, other submodules should utilize the org.jetbrains.intellij.platform.module plugin. This ensures the proper export of output archives and optimizes the build process. For submodules that require only access to the IntelliJ Platform dependency, the org.jetbrains.intellij.platform.base plugin should be applied.

New name and requirements

This release brings major configuration and conceptual changes. In order to help distinguish the new configuration from the old one, version 2.0 of the plugin has a new ID: org.jetbrains.intellij.platform.

Another reason for the name change was confusion of the Gradle IntelliJ Plugin with the Gradle plugin, which is bundled in IntelliJ IDEA and offers actual Gradle integration features. The name “IntelliJ Platform Gradle Plugin” highlights that it is the “IntelliJ Platform Plugin” for the “Gradle” build system.

To make it possible to introduce solutions that address almost all of the issues reported over the last few years, it was necessary to limit support for older versions of the IntelliJ Platform, Gradle, and Java Runtime. IntelliJ Platform Gradle Plugin 2.0 requires the following minimal versions:

  • IntelliJ Platform – 2022.3
  • Gradle – 8.2
  • Java Runtime – 17

Those constraints helped us focus more on recent IntelliJ Platform versions and developer environments, allowing us to close over 100 reported issues, improve project quality, and cover it with more unit and integration tests.

The importance of updating

IntelliJ IDEA 2024.2 introduces changes to the layout of IntelliJ Platform modules. To use version 2024.2+ of an IntelliJ-based IDE for building plugins, migrating to version 2.0 of the IntelliJ Platform Gradle Plugin is essential, as the new layout changes cannot be easily backported to the 1.x branch.

Additionally, Android Studio 2024.1 on macOS has discontinued the use of ZIP archives and now only provides DMG installers, which the 1.x version of the Gradle plugin cannot handle.

As of the 2.0 release, the development of 1.x is now frozen and no more updates are planned.

Next steps

To start using version 2.0 of the IntelliJ Platform Gradle Plugin, visit the documentation pages at IntelliJ Platform SDK | Tooling | IntelliJ Platform Gradle Plugin 2.x, where you will find a proper introduction to all of the new features and changes, a migration guide, and examples of various configurations you may be interested in.

For projects created with the IntelliJ Platform Plugin Template, we advise taking a look at the 2.0.0 pull request applied on top of the obsolete Gradle IntelliJ Plugin 1.x configuration: https://github.com/JetBrains/intellij-platform-plugin-template/pull/458/files

If you have any issues or requests, please submit them to our GitHub Issues page or the JetBrains Platform Slack.

To submit questions or suggestions related to the documentation, please use the feedback form at the bottom of the article.

Subscribe to JetBrains Platform updates