@@ -3,6 +3,7 @@ import org.jetbrains.changelog.markdownToHTML
33import org.jetbrains.grammarkit.tasks.GenerateLexerTask
44import org.jetbrains.grammarkit.tasks.GenerateParserTask
55import org.jetbrains.kotlin.gradle.internal.ensureParentDirsCreated
6+ import org.jetbrains.intellij.platform.gradle.TestFrameworkType
67
78fun properties (key : String ) = providers.gradleProperty(key)
89
@@ -11,7 +12,7 @@ fun environment(key: String) = providers.environmentVariable(key)
1112plugins {
1213 id(" java" ) // Java support
1314 alias(libs.plugins.kotlin) // Kotlin support
14- alias(libs.plugins.gradleIntelliJPlugin ) // Gradle IntelliJ Plugin
15+ alias(libs.plugins.intelliJPlatform ) // Gradle IntelliJ Plugin
1516 alias(libs.plugins.changelog) // Gradle Changelog Plugin
1617 alias(libs.plugins.qodana) // Gradle Qodana Plugin
1718 alias(libs.plugins.kover) // Gradle Kover Plugin
@@ -25,6 +26,11 @@ version = properties("pluginVersion").get()
2526repositories {
2627 mavenLocal()
2728 mavenCentral()
29+
30+ // IntelliJ Platform Gradle Plugin Repositories Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html
31+ intellijPlatform {
32+ defaultRepositories()
33+ }
2834}
2935
3036dependencies {
@@ -34,6 +40,22 @@ dependencies {
3440 implementation(" com.bybutter.sisyphus:sisyphus-grpc:2.1.22" )
3541 implementation(" com.bybutter.sisyphus:sisyphus-jackson-protobuf:2.1.22" )
3642 implementation(" io.grpc:grpc-netty:1.65.0" )
43+
44+ // IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html
45+ intellijPlatform {
46+ create(providers.gradleProperty(" platformType" ), providers.gradleProperty(" platformVersion" ))
47+
48+ // Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins.
49+ bundledPlugins(providers.gradleProperty(" platformBundledPlugins" ).map { it.split(' ,' ) })
50+
51+ // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace.
52+ plugins(providers.gradleProperty(" platformPlugins" ).map { it.split(' ,' ) })
53+
54+ instrumentationTools()
55+ pluginVerifier()
56+ zipSigner()
57+ testFramework(TestFrameworkType .Platform )
58+ }
3759}
3860
3961// Set the JVM language level used to build the project.
@@ -44,20 +66,68 @@ kotlin {
4466 }
4567}
4668
47- // Configure Gradle IntelliJ Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
48- intellij {
49- pluginName = properties(" pluginName" )
50- version = properties(" platformVersion" )
51- type = properties(" platformType" )
69+ // Configure IntelliJ Platform Gradle Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html
70+ intellijPlatform {
71+ pluginConfiguration {
72+ version = providers.gradleProperty(" pluginVersion" )
73+
74+ // Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
75+ description = providers.fileContents(layout.projectDirectory.file(" README.md" )).asText.map {
76+ val start = " <!-- Plugin description -->"
77+ val end = " <!-- Plugin description end -->"
78+
79+ with (it.lines()) {
80+ if (! containsAll(listOf (start, end))) {
81+ throw GradleException (" Plugin description section not found in README.md:\n $start ... $end " )
82+ }
83+ subList(indexOf(start) + 1 , indexOf(end)).joinToString(" \n " ).let (::markdownToHTML)
84+ }
85+ }
5286
53- // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
54- plugins = properties(" platformPlugins" ).map { it.split(' ,' ).map(String ::trim).filter(String ::isNotEmpty) }
87+ val changelog = project.changelog // local variable for configuration cache compatibility
88+ // Get the latest available change notes from the changelog file
89+ changeNotes = providers.gradleProperty(" pluginVersion" ).map { pluginVersion ->
90+ with (changelog) {
91+ renderItem(
92+ (getOrNull(pluginVersion) ? : getUnreleased())
93+ .withHeader(false )
94+ .withEmptySections(false ),
95+ Changelog .OutputType .HTML ,
96+ )
97+ }
98+ }
99+
100+ ideaVersion {
101+ sinceBuild = providers.gradleProperty(" pluginSinceBuild" )
102+ untilBuild = providers.gradleProperty(" pluginUntilBuild" )
103+ }
104+ }
105+
106+ signing {
107+ certificateChain = providers.environmentVariable(" CERTIFICATE_CHAIN" )
108+ privateKey = providers.environmentVariable(" PRIVATE_KEY" )
109+ password = providers.environmentVariable(" PRIVATE_KEY_PASSWORD" )
110+ }
111+
112+ publishing {
113+ token = providers.environmentVariable(" PUBLISH_TOKEN" )
114+ // The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
115+ // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
116+ // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
117+ channels = providers.gradleProperty(" pluginVersion" ).map { listOf (it.substringAfter(' -' , " " ).substringBefore(' .' ).ifEmpty { " default" }) }
118+ }
119+
120+ pluginVerification {
121+ ides {
122+ recommended()
123+ }
124+ }
55125}
56126
57127// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
58128changelog {
59129 groups.empty()
60- repositoryUrl = properties (" pluginRepositoryUrl" )
130+ repositoryUrl = providers.gradleProperty (" pluginRepositoryUrl" )
61131}
62132
63133// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration
@@ -76,53 +146,6 @@ tasks {
76146 gradleVersion = properties(" gradleVersion" ).get()
77147 }
78148
79- patchPluginXml {
80- version = properties(" pluginVersion" )
81- sinceBuild = properties(" pluginSinceBuild" )
82- untilBuild = properties(" pluginUntilBuild" )
83-
84- // Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
85- pluginDescription =
86- providers.fileContents(layout.projectDirectory.file(" README.md" )).asText.map {
87- val start = " <!-- Plugin description -->"
88- val end = " <!-- Plugin description end -->"
89-
90- with (it.lines()) {
91- if (! containsAll(listOf (start, end))) {
92- throw GradleException (" Plugin description section not found in README.md:\n $start ... $end " )
93- }
94- subList(indexOf(start) + 1 , indexOf(end)).joinToString(" \n " ).let (::markdownToHTML)
95- }
96- }
97-
98- val changelog = project.changelog // local variable for configuration cache compatibility
99- // Get the latest available change notes from the changelog file
100- changeNotes =
101- properties(" pluginVersion" ).map { pluginVersion ->
102- with (changelog) {
103- renderItem(
104- (getOrNull(pluginVersion) ? : getUnreleased())
105- .withHeader(false )
106- .withEmptySections(false ),
107- Changelog .OutputType .HTML ,
108- )
109- }
110- }
111- }
112-
113- // Configure UI tests plugin
114- // Read more: https://github.com/JetBrains/intellij-ui-test-robot
115- runIdeForUiTests {
116- systemProperty(" robot-server.port" , " 8082" )
117- systemProperty(" ide.mac.message.dialogs.as.sheets" , " false" )
118- systemProperty(" jb.privacy.policy.text" , " <!--999.999-->" )
119- systemProperty(" jb.consents.confirmation.enabled" , " false" )
120- }
121-
122- runIde {
123- jvmArguments.add(" -Didea.ProcessCanceledException=disabled" )
124- }
125-
126149 generateLexer {
127150 sourceFile = layout.projectDirectory.file(" src/main/grammar/protobuf.flex" )
128151 targetOutputDir =
@@ -154,7 +177,7 @@ tasks {
154177 }
155178
156179 prepareSandbox {
157- val file = layout.buildDirectory. file(" idea-sandbox/config/ disabled_plugins.txt" ).get().asFile
180+ val file = sandboxConfigDirectory. file(" disabled_plugins.txt" ).get().asFile
158181 doLast {
159182 file.ensureParentDirsCreated()
160183 file.writeText(
@@ -164,20 +187,11 @@ tasks {
164187 },
165188 )
166189 }
190+
167191 }
168192
169193 publishPlugin {
170- dependsOn(" patchChangelog" )
171- token = environment(" PUBLISH_TOKEN" )
172- // pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
173- // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
174- // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
175- channels =
176- properties(" pluginVersion" ).map {
177- listOf (
178- it.substringAfter(' -' , " " ).substringBefore(' .' ).ifEmpty { " default" },
179- )
180- }
194+ dependsOn(patchChangelog)
181195 }
182196
183197 compileKotlin {
@@ -192,3 +206,24 @@ sourceSets {
192206 }
193207 }
194208}
209+
210+ intellijPlatformTesting {
211+ runIde {
212+ register(" runIdeForUiTests" ) {
213+ task {
214+ jvmArgumentProviders + = CommandLineArgumentProvider {
215+ listOf (
216+ " -Drobot-server.port=8082" ,
217+ " -Dide.mac.message.dialogs.as.sheets=false" ,
218+ " -Djb.privacy.policy.text=<!--999.999-->" ,
219+ " -Djb.consents.confirmation.enabled=false" ,
220+ )
221+ }
222+ }
223+
224+ plugins {
225+ robotServerPlugin()
226+ }
227+ }
228+ }
229+ }
0 commit comments