11import org.jetbrains.changelog.Changelog
22import org.jetbrains.changelog.markdownToHTML
33import org.jetbrains.intellij.platform.gradle.Constants.Constraints
4+ import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
45import org.jetbrains.intellij.platform.gradle.TestFrameworkType
6+ import org.jetbrains.intellij.platform.gradle.tasks.PrepareSandboxTask
57import java.net.URI
68import java.net.http.HttpClient
79import java.net.http.HttpRequest
@@ -29,7 +31,7 @@ kotlin {
2931// Configure project's dependencies
3032repositories {
3133 mavenCentral()
32-
34+
3335 // IntelliJ Platform Gradle Plugin Repositories Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html
3436 intellijPlatform {
3537 defaultRepositories()
@@ -41,39 +43,19 @@ dependencies {
4143 compileOnly(libs.kotlinxSerialization)
4244 testImplementation(kotlin(" test" ))
4345 testImplementation(libs.junit)
44-
46+
4547 // IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html
4648 intellijPlatform {
4749 create(
4850 providers.gradleProperty(" platformType" ),
4951 providers.gradleProperty(" platformVersion" ),
5052 useInstaller = false
5153 )
52-
54+
5355 // Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins.
5456 bundledPlugins(providers.gradleProperty(" platformBundledPlugins" ).map { it.split(' ,' ) })
55-
56- // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace.
57- // plugins(providers.gradleProperty("platformPlugins").map { it.split(',') })
58-
59- val platformPlugins = ArrayList <String >()
60- // val localLsp4ij = file("../lsp4ij.old/build/idea-sandbox/plugins/LSP4IJ").absoluteFile
61- // if (localLsp4ij.isDirectory) {
62- // // In case Gradle fails to build because it can't find some missing jar, try deleting
63- // // ~/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/unzipped.com.jetbrains.plugins/com.redhat.devtools.lsp4ij*
64- // localPlugin(localLsp4ij.toString())
65- // } else {
66- // // When running on CI or when there's no local lsp4ij
67- // val latestLsp4ijNightlyVersion = fetchLatestLsp4ijNightlyVersion()
68- // platformPlugins.add("com.redhat.devtools.lsp4ij:$latestLsp4ijNightlyVersion@nightly")
69- // }
70-
71- platformPlugins.add(" com.redhat.devtools.lsp4ij:0.9.0" )
72- // Uses `platformPlugins` property from the gradle.properties file.
73- platformPlugins.addAll(providers.gradleProperty(" platformPlugins" ).map { it.split(' ,' ).map(String ::trim).filter(String ::isNotEmpty) }.get())
74-
75- plugins(platformPlugins)
76-
57+ plugins(providers.gradleProperty(" platformPlugins" ).map { it.split(' ,' ) })
58+
7759 pluginVerifier()
7860 zipSigner()
7961 testFramework(TestFrameworkType .Platform )
@@ -85,20 +67,20 @@ intellijPlatform {
8567 pluginConfiguration {
8668 name = providers.gradleProperty(" pluginName" )
8769 version = providers.gradleProperty(" pluginVersion" )
88-
70+
8971 // Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
9072 description = providers.fileContents(layout.projectDirectory.file(" README.md" )).asText.map {
9173 val start = " <!-- Plugin description -->"
9274 val end = " <!-- Plugin description end -->"
93-
75+
9476 with (it.lines()) {
9577 if (! containsAll(listOf (start, end))) {
9678 throw GradleException (" Plugin description section not found in README.md:\n $start ... $end " )
9779 }
9880 subList(indexOf(start) + 1 , indexOf(end)).joinToString(" \n " ).let (::markdownToHTML)
9981 }
10082 }
101-
83+
10284 val changelog = project.changelog // local variable for configuration cache compatibility
10385 // Get the latest available change notes from the changelog file
10486 changeNotes = providers.gradleProperty(" pluginVersion" ).map { pluginVersion ->
@@ -111,19 +93,19 @@ intellijPlatform {
11193 )
11294 }
11395 }
114-
96+
11597 ideaVersion {
11698 sinceBuild = providers.gradleProperty(" pluginSinceBuild" )
11799 untilBuild = providers.gradleProperty(" pluginUntilBuild" )
118100 }
119101 }
120-
102+
121103 signing {
122104 certificateChain = providers.environmentVariable(" CERTIFICATE_CHAIN" )
123105 privateKey = providers.environmentVariable(" PRIVATE_KEY" )
124106 password = providers.environmentVariable(" PRIVATE_KEY_PASSWORD" )
125107 }
126-
108+
127109 publishing {
128110 token = providers.environmentVariable(" PUBLISH_TOKEN" )
129111 // The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
@@ -132,7 +114,7 @@ intellijPlatform {
132114 channels = providers.gradleProperty(" pluginVersion" )
133115 .map { listOf (it.substringAfter(' -' , " " ).substringBefore(' .' ).ifEmpty { " default" }) }
134116 }
135-
117+
136118 pluginVerification {
137119 ides {
138120 recommended()
@@ -158,6 +140,15 @@ kover {
158140 }
159141}
160142
143+ val prepareSandboxConfig: PrepareSandboxTask .() -> Unit = {
144+ from(" .." ) {
145+ include(" package.json" , " language-configuration.json" , " syntaxes/**/*" , " bundled/**/*" )
146+ exclude(" **/bin" )
147+ exclude(" **/__pycache__" )
148+ into(" robotcode4ij/data" )
149+ }
150+ }
151+
161152tasks {
162153 runIde {
163154 // From https://app.slack.com/client/T5P9YATH9/C5U8BM1MK
@@ -166,25 +157,20 @@ tasks {
166157 // systemProperty("terminal.new.ui", "false")
167158 // systemProperty("ide.tree.painter.compact.default", "true")
168159 }
169-
160+
170161 wrapper {
171162 gradleVersion = providers.gradleProperty(" gradleVersion" ).get()
172163 }
173-
164+
174165 publishPlugin {
175166 dependsOn(patchChangelog)
176167 }
177- prepareSandbox {
178- from(" .." ) {
179- include(" package.json" , " language-configuration.json" , " syntaxes/**/*" , " bundled/**/*" )
180-
181- exclude(" **/bin" )
182- exclude(" **/__pycache__" )
183- into(" robotcode4ij/data" )
184- }
185- }
168+
169+ prepareSandbox(prepareSandboxConfig)
186170}
187171
172+
173+
188174// Configure UI tests plugin
189175// Read more: https://github.com/JetBrains/intellij-ui-test-robot
190176val runIdeForUiTests by intellijPlatformTesting.runIde.registering {
@@ -198,12 +184,26 @@ val runIdeForUiTests by intellijPlatformTesting.runIde.registering {
198184 )
199185 }
200186 }
201-
187+
188+ prepareSandboxTask(prepareSandboxConfig)
189+
202190 plugins {
203191 robotServerPlugin(Constraints .LATEST_VERSION )
204192 }
205193}
206194
195+ val runIdePyCharmProf by intellijPlatformTesting.runIde.registering {
196+ type = IntelliJPlatformType .PyCharmProfessional
197+
198+ prepareSandboxTask(prepareSandboxConfig)
199+ }
200+
201+ val runIdeIntellijIdeaC by intellijPlatformTesting.runIde.registering {
202+ type = IntelliJPlatformType .IntellijIdeaCommunity
203+
204+ prepareSandboxTask(prepareSandboxConfig)
205+ }
206+
207207fun fetchLatestLsp4ijNightlyVersion (): String {
208208 val client = HttpClient .newBuilder().build();
209209 var onlineVersion = " "
@@ -220,10 +220,10 @@ fun fetchLatestLsp4ijNightlyVersion(): String {
220220 onlineVersion = matcher.group(1 )
221221 println (" Latest approved nightly build: $onlineVersion " )
222222 }
223- } catch (e: Exception ) {
223+ } catch (e: Exception ) {
224224 println (" Failed to fetch LSP4IJ nightly build version: ${e.message} " )
225225 }
226-
226+
227227 val minVersion = " 0.0.1-20231213-012910"
228228 return if (minVersion < onlineVersion) onlineVersion else minVersion
229229}
0 commit comments