Skip to content

Commit 65aeceb

Browse files
committed
Allow lsp4ij local build
1 parent 4eb6296 commit 65aeceb

File tree

3 files changed

+64
-18
lines changed

3 files changed

+64
-18
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ bin
77
.classpath
88
/.nrepl-port
99
.lsp/.cache
10-
.clj-kondo/.cache
10+
.clj-kondo
11+
!.clj-kondo/.config
1112
.project
1213
.settings

build.gradle.kts

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
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+
}
415

516
plugins {
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

1627
repositories {
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-
5259
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"))
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

6081
changelog {
@@ -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+
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ platformVersion = 2023.3
1919

2020
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
2121
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
22-
platformPlugins = com.intellij.java, com.redhat.devtools.lsp4ij:0.10.0
22+
platformPlugins = com.intellij.java
2323

2424
# Gradle Releases -> https://github.com/gradle/gradle/releases
2525
gradleVersion = 7.6.1

0 commit comments

Comments
 (0)