11import org.jetbrains.changelog.markdownToHTML
2-
3- fun properties (key : String ) = project.findProperty(key).toString()
2+ import java.net.URI
3+ import java.net.http.HttpClient
4+ import java.net.http.HttpRequest
5+ import java.net.http.HttpResponse
6+ import java.time.Duration
7+ import java.time.temporal.ChronoUnit
8+ import java.util.regex.Pattern
9+
10+ fun properties (key : String ) = providers.gradleProperty(key)
11+ fun environment (key : String ) = providers.environmentVariable(key)
12+ fun prop (name : String ): String {
13+ return properties(name).get()
14+ }
415
516plugins {
6- id(" org.jetbrains.kotlin.jvm" ) version " 1.9.0 "
17+ id(" org.jetbrains.kotlin.jvm" ) version " 1.9.10 "
718 id(" dev.clojurephant.clojure" ) version " 0.7.0"
819 id(" org.jetbrains.intellij" ) version " 1.17.4"
920 id(" org.jetbrains.changelog" ) version " 1.3.1"
1021 id(" org.jetbrains.grammarkit" ) version " 2021.2.2"
1122}
1223
13- group = properties (" pluginGroup" )
14- version = properties (" pluginVersion" )
24+ group = prop (" pluginGroup" )
25+ version = prop (" pluginVersion" )
1526
1627repositories {
1728 mavenLocal()
@@ -45,16 +56,26 @@ sourceSets {
4556 }
4657}
4758
48- // Useful to override another IC platforms from env
49- val platformVersion = System .getenv(" PLATFORM_VERSION" ) ? : properties(" platformVersion" )
50- val platformPlugins = System .getenv(" PLATFORM_PLUGINS" ) ? : properties(" platformPlugins" )
51-
5259intellij {
53- pluginName.set(properties(" pluginName" ))
54- version.set(platformVersion)
55- type.set(properties(" platformType" ))
56- plugins.set(platformPlugins.split(' ,' ).map(String ::trim).filter(String ::isNotEmpty))
60+ pluginName.set(prop(" pluginName" ))
61+ version.set(prop(" platformVersion" ))
62+ type.set(prop(" platformType" ))
5763 updateSinceUntilBuild.set(false )
64+
65+ val platformPlugins = ArrayList <Any >()
66+ val localLsp4ij = file(" ../lsp4ij/build/idea-sandbox/plugins/LSP4IJ" ).absoluteFile
67+ if (localLsp4ij.isDirectory) {
68+ // In case Gradle fails to build because it can't find some missing jar, try deleting
69+ // ~/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/unzipped.com.jetbrains.plugins/com.redhat.devtools.lsp4ij*
70+ platformPlugins.add(localLsp4ij)
71+ } else {
72+ // When running on CI or when there's no local lsp4ij
73+ val latestLsp4ijNightlyVersion = fetchLatestLsp4ijNightlyVersion()
74+ platformPlugins.add(" com.redhat.devtools.lsp4ij:$latestLsp4ijNightlyVersion @nightly" )
75+ }
76+ // Uses `platformPlugins` property from the gradle.properties file.
77+ platformPlugins.addAll(properties(" platformPlugins" ).map { it.split(' ,' ).map(String ::trim).filter(String ::isNotEmpty) }.get())
78+ plugins.set(platformPlugins)
5879}
5980
6081changelog {
@@ -84,7 +105,7 @@ tasks {
84105 }
85106
86107 wrapper {
87- gradleVersion = properties (" gradleVersion" )
108+ gradleVersion = prop (" gradleVersion" )
88109 }
89110
90111 patchPluginXml {
@@ -107,13 +128,13 @@ tasks {
107128 // Get the latest available change notes from the changelog file
108129 changeNotes.set(provider {
109130 changelog.run {
110- getOrNull(properties (" pluginVersion" )) ? : getLatest()
131+ getOrNull(prop (" pluginVersion" )) ? : getLatest()
111132 }.toHTML()
112133 })
113134 }
114135
115136 runPluginVerifier {
116- ideVersions.set(properties (" pluginVerifierIdeVersions" ).split(' ,' ).map(String ::trim).filter(String ::isNotEmpty))
137+ ideVersions.set(prop (" pluginVerifierIdeVersions" ).split(' ,' ).map(String ::trim).filter(String ::isNotEmpty))
117138 }
118139
119140 // Configure UI tests plugin
@@ -171,3 +192,27 @@ clojure.builds.named("main") {
171192 aotAll()
172193 reflection.set(" fail" )
173194}
195+
196+ fun fetchLatestLsp4ijNightlyVersion (): String {
197+ val client = HttpClient .newBuilder().build();
198+ var onlineVersion = " "
199+ try {
200+ val request: HttpRequest = HttpRequest .newBuilder()
201+ .uri(URI (" https://plugins.jetbrains.com/api/plugins/23257/updates?channel=nightly&size=1" ))
202+ .GET ()
203+ .timeout(Duration .of(10 , ChronoUnit .SECONDS ))
204+ .build()
205+ val response = client.send(request, HttpResponse .BodyHandlers .ofString());
206+ val pattern = Pattern .compile(" \" version\" :\" ([^\" ]+)\" " )
207+ val matcher = pattern.matcher(response.body())
208+ if (matcher.find()) {
209+ onlineVersion = matcher.group(1 )
210+ println (" Latest approved nightly build: $onlineVersion " )
211+ }
212+ } catch (e: Exception ) {
213+ println (" Failed to fetch LSP4IJ nightly build version: ${e.message} " )
214+ }
215+
216+ val minVersion = " 0.0.1-20231213-012910"
217+ return if (minVersion < onlineVersion) onlineVersion else minVersion
218+ }
0 commit comments