|
1 | 1 | import com.adarshr.gradle.testlogger.theme.ThemeType
|
2 | 2 | import org.jetbrains.changelog.markdownToHTML
|
3 |
| -import org.jetbrains.intellij.tasks.RunPluginVerifierTask.VerificationReportsFormats.* |
4 | 3 | import org.jetbrains.intellij.tasks.RunPluginVerifierTask.FailureLevel.*
|
| 4 | +import org.jetbrains.intellij.tasks.RunPluginVerifierTask.VerificationReportsFormats.* |
| 5 | +import java.net.URI |
| 6 | +import java.net.http.HttpClient |
| 7 | +import java.net.http.HttpRequest |
| 8 | +import java.net.http.HttpResponse |
| 9 | +import java.time.Duration |
| 10 | +import java.time.temporal.ChronoUnit |
| 11 | +import java.util.regex.Pattern |
5 | 12 |
|
6 | 13 | fun properties(key: String) = providers.gradleProperty(key)
|
7 | 14 | fun environment(key: String) = providers.environmentVariable(key)
|
@@ -132,18 +139,16 @@ intellij {
|
132 | 139 | if (localLsp4ij.isDirectory) {
|
133 | 140 | // In case Gradle fails to build because it can't find some missing jar, try deleting
|
134 | 141 | // ~/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/unzipped.com.jetbrains.plugins/com.redhat.devtools.lsp4ij*
|
135 |
| - platformPlugins.add(localLsp4ij) |
| 142 | + platformPlugins.add(localLsp4ij) |
136 | 143 | } else {
|
137 | 144 | // When running on CI or when there's no local lsp4ij
|
138 |
| - //TODO automatically fetch the latest nightly build version |
139 |
| - platformPlugins.add("com.redhat.devtools.lsp4ij:0.0.1-20231211-102151@nightly") |
| 145 | + val latestLsp4ijNightlyVersion = fetchLatestLsp4ijNightlyVersion() |
| 146 | + platformPlugins.add("com.redhat.devtools.lsp4ij:$latestLsp4ijNightlyVersion@nightly") |
140 | 147 | }
|
141 | 148 | //Uses `platformPlugins` property from the gradle.properties file.
|
142 | 149 | platformPlugins.addAll(properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) }.get())
|
143 | 150 | println("platformPlugins: $platformPlugins")
|
144 | 151 | plugins = platformPlugins
|
145 |
| - |
146 |
| - |
147 | 152 | }
|
148 | 153 |
|
149 | 154 | configurations {
|
@@ -286,3 +291,27 @@ tasks {
|
286 | 291 | dependsOn(jacocoTestReport)
|
287 | 292 | }
|
288 | 293 | }
|
| 294 | + |
| 295 | +fun fetchLatestLsp4ijNightlyVersion(): String { |
| 296 | + val client = HttpClient.newBuilder().build(); |
| 297 | + var onlineVersion = "" |
| 298 | + try { |
| 299 | + val request: HttpRequest = HttpRequest.newBuilder() |
| 300 | + .uri(URI("https://plugins.jetbrains.com/api/plugins/23257/updates?channel=nightly&size=1")) |
| 301 | + .GET() |
| 302 | + .timeout(Duration.of(10, ChronoUnit.SECONDS)) |
| 303 | + .build() |
| 304 | + val response = client.send(request, HttpResponse.BodyHandlers.ofString()); |
| 305 | + val pattern = Pattern.compile("\"version\":\"([^\"]+)\"") |
| 306 | + val matcher = pattern.matcher(response.body()) |
| 307 | + if (matcher.find()) { |
| 308 | + onlineVersion = matcher.group(1) |
| 309 | + println("Latest approved nightly build: $onlineVersion") |
| 310 | + } |
| 311 | + } catch (e:Exception) { |
| 312 | + println("Failed to fetch LSP4IJ nightly build version: ${e.message}") |
| 313 | + } |
| 314 | + |
| 315 | + val minVersion = "0.0.1-20231213-012910" |
| 316 | + return if (minVersion < onlineVersion) onlineVersion else minVersion |
| 317 | +} |
0 commit comments