Skip to content

Commit 8186159

Browse files
committed
impl: migrate platform plugin to latest 2.x
IntelliJ Platform Gradle Plugin 2.x is the build system that supersedes the Gradle IntelliJ Plugin 1.x, and this is the version that also comes with the ability to provide unlimited until build support. This is a major overhaul of the DSL, I've tested these changes locally with IntelliJ Community 2022 (the minimum supported version), and I've also compared the plugin.xml and the zip content with a previous version to make sure it is generated correctly.
1 parent 62d4258 commit 8186159

File tree

3 files changed

+111
-55
lines changed

3 files changed

+111
-55
lines changed

build.gradle.kts

Lines changed: 104 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import org.jetbrains.changelog.Changelog
22
import org.jetbrains.changelog.markdownToHTML
3+
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
34

45
fun properties(key: String) = providers.gradleProperty(key)
56
fun environment(key: String) = providers.environmentVariable(key)
@@ -17,68 +18,58 @@ plugins {
1718
group = properties("pluginGroup").get()
1819
version = properties("pluginVersion").get()
1920

21+
// Set the JVM language level used to build the project.
22+
kotlin {
23+
jvmToolchain(17)
24+
}
25+
2026
// Configure project's dependencies
2127
repositories {
2228
mavenCentral()
29+
// IntelliJ Platform Gradle Plugin Repositories Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html
30+
intellijPlatform {
31+
defaultRepositories()
32+
}
2333
}
2434

2535
// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
2636
dependencies {
27-
// implementation(libs.annotations)
37+
// implementation(libs.annotations)
2838
// We need kotlinx-serialization-json >= 1.7.0 to support allowComments, as
2939
// devcontainer.json files often have comments and therefore use
3040
// nonstandard JSON syntax. This dependency should be marked compileOnly
3141
// once the minimum IDE version we support (pluginSinceBuild in
3242
// gradle.properties) is at least 251, which includes version 1.7.2.
3343
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0")
34-
}
3544

36-
// Set the JVM language level used to build the project.
37-
kotlin {
38-
jvmToolchain(17)
39-
}
45+
testImplementation("junit:junit:4.13.2")
4046

41-
// Configure Gradle IntelliJ Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
42-
intellij {
43-
pluginName = properties("pluginName")
44-
version = properties("platformVersion")
45-
type = properties("platformType")
47+
// IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html
48+
intellijPlatform {
49+
intellijIdeaCommunity(providers.gradleProperty("platformVersion"))
4650

47-
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
48-
plugins = properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) }
49-
}
50-
51-
// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
52-
changelog {
53-
groups.empty()
54-
repositoryUrl = properties("pluginRepositoryUrl")
55-
}
51+
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace.
52+
bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') })
5653

57-
// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration
58-
koverReport {
59-
defaults {
60-
xml {
61-
onCheck = true
62-
}
54+
pluginVerifier()
6355
}
6456
}
6557

66-
tasks {
67-
wrapper {
68-
gradleVersion = properties("gradleVersion").get()
69-
}
58+
// Configure Gradle IntelliJ Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
59+
intellijPlatform {
60+
buildSearchableOptions = true
61+
instrumentCode = true
7062

71-
patchPluginXml {
72-
version = properties("pluginVersion")
73-
sinceBuild = properties("pluginSinceBuild")
74-
untilBuild = properties("pluginUntilBuild")
63+
pluginConfiguration {
64+
name = providers.gradleProperty("pluginName")
65+
version = providers.gradleProperty("pluginVersion")
7566

7667
// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
77-
pluginDescription = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map {
68+
description = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map {
7869
val start = "<!-- Plugin description -->"
7970
val end = "<!-- Plugin description end -->"
8071

81-
with (it.lines()) {
72+
with(it.lines()) {
8273
if (!containsAll(listOf(start, end))) {
8374
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
8475
}
@@ -88,7 +79,7 @@ tasks {
8879

8980
val changelog = project.changelog // local variable for configuration cache compatibility
9081
// Get the latest available change notes from the changelog file
91-
changeNotes = properties("pluginVersion").map { pluginVersion ->
82+
changeNotes = providers.gradleProperty("pluginVersion").map { pluginVersion ->
9283
with(changelog) {
9384
renderItem(
9485
(getOrNull(pluginVersion) ?: getUnreleased())
@@ -98,29 +89,93 @@ tasks {
9889
)
9990
}
10091
}
92+
93+
ideaVersion {
94+
sinceBuild = providers.gradleProperty("pluginSinceBuild")
95+
untilBuild = providers.gradleProperty("pluginUntilBuild")
96+
}
10197
}
10298

103-
// Configure UI tests plugin
104-
// Read more: https://github.com/JetBrains/intellij-ui-test-robot
105-
runIdeForUiTests {
106-
systemProperty("robot-server.port", "8082")
107-
systemProperty("ide.mac.message.dialogs.as.sheets", "false")
108-
systemProperty("jb.privacy.policy.text", "<!--999.999-->")
109-
systemProperty("jb.consents.confirmation.enabled", "false")
99+
pluginVerification {
100+
ides {
101+
providers.gradleProperty("verifyVersions").get().split(',').map(String::trim).forEach { version ->
102+
ide(IntelliJPlatformType.IntellijIdeaCommunity, version)
103+
}
104+
}
110105
}
111106

112-
signPlugin {
107+
signing {
113108
certificateChain = environment("CERTIFICATE_CHAIN")
114109
privateKey = environment("PRIVATE_KEY")
115110
password = environment("PRIVATE_KEY_PASSWORD")
116111
}
117112

118-
publishPlugin {
119-
dependsOn("patchChangelog")
120-
token = environment("PUBLISH_TOKEN")
113+
publishing {
114+
token = providers.environmentVariable("PUBLISH_TOKEN")
121115
// The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
122116
// Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
123117
// https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
124-
channels = properties("pluginVersion").map { listOf(it.substringAfter('-', "").substringBefore('.').ifEmpty { "default" }) }
118+
channels = providers.gradleProperty("pluginVersion")
119+
.map { listOf(it.substringAfter('-', "").substringBefore('.').ifEmpty { "default" }) }
120+
}
121+
}
122+
123+
124+
// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
125+
changelog {
126+
version.set(properties("pluginVersion"))
127+
groups.set(emptyList())
128+
}
129+
130+
// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration
131+
kover {
132+
reports {
133+
total {
134+
xml {
135+
onCheck = true
136+
}
137+
}
138+
}
139+
}
140+
141+
// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin
142+
qodana {
143+
cachePath.set(projectDir.resolve(".qodana").canonicalPath)
144+
resultsPath.set(projectDir.resolve("build/reports/inspections").canonicalPath)
145+
}
146+
147+
tasks {
148+
wrapper {
149+
gradleVersion = properties("gradleVersion").get()
150+
}
151+
152+
buildPlugin {
153+
archiveBaseName = providers.gradleProperty("pluginName").get()
154+
// exclude { "coroutines" in it.name }
155+
}
156+
157+
publishPlugin {
158+
dependsOn(patchChangelog)
125159
}
126160
}
161+
162+
intellijPlatformTesting {
163+
runIde {
164+
register("runIdeForUiTests") {
165+
task {
166+
jvmArgumentProviders += CommandLineArgumentProvider {
167+
listOf(
168+
"-Drobot-server.port=8082",
169+
"-Dide.mac.message.dialogs.as.sheets=false",
170+
"-Djb.privacy.policy.text=<!--999.999-->",
171+
"-Djb.consents.confirmation.enabled=false",
172+
)
173+
}
174+
}
175+
176+
plugins {
177+
robotServerPlugin()
178+
}
179+
}
180+
}
181+
}

gradle.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ pluginUntilBuild = 251.*
1313
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
1414
platformType = IC
1515
platformVersion = 2022.3.3
16-
16+
# available releases listed at: https://data.services.jetbrains.com/products?code=IC
17+
verifyVersions=2025.1
1718
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
1819
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
19-
platformPlugins=com.jetbrains.codeWithMe, org.jetbrains.plugins.terminal
20+
platformBundledPlugins=com.jetbrains.codeWithMe, org.jetbrains.plugins.terminal
2021

2122
# Gradle Releases -> https://github.com/gradle/gradle/releases
2223
gradleVersion = 8.6

gradle/libs.versions.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ annotations = "24.1.0"
55
# plugins
66
kotlin = "2.0.0"
77
changelog = "2.2.0"
8-
gradleIntelliJPlugin = "1.17.2"
9-
qodana = "2024.1.5"
10-
kover = "0.7.6"
8+
gradleIntelliJPlugin = "2.6.0"
9+
qodana = "2025.1.1"
10+
kover = "0.9.1"
1111

1212
[libraries]
1313
annotations = { group = "org.jetbrains", name = "annotations", version.ref = "annotations" }
1414

1515
[plugins]
1616
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
17-
gradleIntelliJPlugin = { id = "org.jetbrains.intellij", version.ref = "gradleIntelliJPlugin" }
17+
gradleIntelliJPlugin = { id = "org.jetbrains.intellij.platform", version.ref = "gradleIntelliJPlugin" }
1818
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
1919
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
2020
qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" }

0 commit comments

Comments
 (0)