1
1
import 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
+ }
4
15
5
16
plugins {
6
- id(" org.jetbrains.kotlin.jvm" ) version " 1.9.0 "
17
+ id(" org.jetbrains.kotlin.jvm" ) version " 1.9.10 "
7
18
id(" dev.clojurephant.clojure" ) version " 0.7.0"
8
19
id(" org.jetbrains.intellij" ) version " 1.17.4"
9
20
id(" org.jetbrains.changelog" ) version " 1.3.1"
10
21
id(" org.jetbrains.grammarkit" ) version " 2021.2.2"
11
22
}
12
23
13
- group = properties (" pluginGroup" )
14
- version = properties (" pluginVersion" )
24
+ group = prop (" pluginGroup" )
25
+ version = prop (" pluginVersion" )
15
26
16
27
repositories {
17
28
mavenLocal()
@@ -45,16 +56,26 @@ sourceSets {
45
56
}
46
57
}
47
58
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
-
52
59
intellij {
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" ))
57
63
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)
58
79
}
59
80
60
81
changelog {
@@ -84,7 +105,7 @@ tasks {
84
105
}
85
106
86
107
wrapper {
87
- gradleVersion = properties (" gradleVersion" )
108
+ gradleVersion = prop (" gradleVersion" )
88
109
}
89
110
90
111
patchPluginXml {
@@ -107,13 +128,13 @@ tasks {
107
128
// Get the latest available change notes from the changelog file
108
129
changeNotes.set(provider {
109
130
changelog.run {
110
- getOrNull(properties (" pluginVersion" )) ? : getLatest()
131
+ getOrNull(prop (" pluginVersion" )) ? : getLatest()
111
132
}.toHTML()
112
133
})
113
134
}
114
135
115
136
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))
117
138
}
118
139
119
140
// Configure UI tests plugin
@@ -171,3 +192,27 @@ clojure.builds.named("main") {
171
192
aotAll()
172
193
reflection.set(" fail" )
173
194
}
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