-
Notifications
You must be signed in to change notification settings - Fork 51
/
build.gradle.kts
329 lines (291 loc) · 12.3 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
import com.adarshr.gradle.testlogger.theme.ThemeType
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.intellij.tasks.RunPluginVerifierTask.FailureLevel.*
import org.jetbrains.intellij.tasks.RunPluginVerifierTask.VerificationReportsFormats.*
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
import java.time.Duration
import java.time.temporal.ChronoUnit
import java.util.regex.Pattern
fun properties(key: String) = providers.gradleProperty(key)
fun environment(key: String) = providers.environmentVariable(key)
fun prop(name: String): String {
return properties(name).get()
}
plugins {
java // Java support
alias(libs.plugins.kotlin) // Kotlin support
alias(libs.plugins.gradleIntelliJPlugin) // Gradle IntelliJ Plugin
alias(libs.plugins.changelog) // Gradle Changelog Plugin
alias(libs.plugins.testLogger) // Nice test logs
jacoco // Code coverage
}
group = prop("pluginGroup")
version = prop("pluginVersion")
val quarkusVersion = prop("quarkusVersion")
val lsp4mpVersion = prop("lsp4mpVersion")
val quarkusLsVersion = prop("quarkusLsVersion")
val quteLsVersion = prop("quteLsVersion")
// Configure project's dependencies
repositories {
mavenLocal()
mavenCentral()
maven { url = uri("https://repository.jboss.org/nexus/content/repositories/snapshots") }
maven { url = uri("https://repository.jboss.org/nexus/content/groups/public") }
maven { url = uri("https://repo.eclipse.org/content/repositories/lsp4mp-snapshots") }
maven { url = uri("https://repo.eclipse.org/content/repositories/lsp4mp-releases") }
maven { url = uri("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies") }
}
val lsp: Configuration by configurations.creating
sourceSets {
named("test") {
java.srcDir("src/test/java")
java.srcDir("intellij-community/java/testFramework/src")
java.srcDir("intellij-community/platform/external-system-api/testFramework/src")
java.srcDir("intellij-community/platform/external-system-impl/testSrc")
java.srcDir("intellij-community/platform/lang-impl/testSources")
java.srcDir("intellij-community/platform/testFramework/extensions/src")
java.srcDir("intellij-community/plugins/gradle/src")
java.srcDir("intellij-community/plugins/gradle/testSources")
java.srcDir("intellij-community/plugins/gradle/tooling-extension-impl/testSources")
java.srcDir("intellij-community/plugins/maven/src/test/java")
java.srcDir("intellij-community/plugins/maven/testFramework/src")
resources.srcDir("src/test/resources")
}
create("integrationTest") {
java.srcDir("src/it/java")
resources.srcDir("src/it/resources")
compileClasspath += sourceSets.main.get().output
compileClasspath += configurations.testImplementation.get()
runtimeClasspath += compileClasspath + sourceSets.test.get().output
}
}
// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
dependencies {
implementation("org.zeroturnaround:zt-zip:1.14")
implementation("org.jsoup:jsoup:1.17.1")
implementation("com.vladsch.flexmark:flexmark-html2md-converter:0.64.8") {
exclude(group="com.vladsch.flexmark", module= "flexmark-jira-converter")
}
implementation("com.google.code.gson:gson:2.10.1") //Need to ensure we don't get telemetry's old gson version
implementation("io.quarkus:quarkus-core:$quarkusVersion") {
isTransitive = false
}
implementation("io.quarkus:quarkus-core-deployment:$quarkusVersion") {
exclude(group = "org.aesh")
exclude(group = "org.apache.commons")
exclude(group = "org.wildfly.common")
exclude(group = "io.quarkus.gizmo")
exclude(group = "org.ow2.asm")
exclude(group = "io.quarkus")
exclude(group = "org.eclipse.sisu")
exclude(group = "org.graalvm.sdk")
exclude(group = "org.junit.platform")
exclude(group = "org.junit.jupiter")
}
implementation("io.quarkus:quarkus-arc:$quarkusVersion") {
isTransitive = false
}
implementation("org.eclipse.lsp4mp:org.eclipse.lsp4mp.ls:$lsp4mpVersion") {
exclude("org.eclipse.lsp4j")
}
// Exclude all lsp4j dependencies to use LSP4J from LSP4IJ
implementation("com.redhat.microprofile:com.redhat.qute.ls:$quteLsVersion") {
exclude("org.eclipse.lsp4j")
}
lsp("org.eclipse.lsp4mp:org.eclipse.lsp4mp.ls:$lsp4mpVersion:uber") {
isTransitive = false
}
lsp("com.redhat.microprofile:com.redhat.quarkus.ls:$quarkusLsVersion") {
isTransitive = false
}
lsp("com.redhat.microprofile:com.redhat.qute.ls:$quteLsVersion:uber") {
isTransitive = false
}
implementation(files(layout.buildDirectory.dir("server")) {
builtBy("copyDeps")
})
testImplementation("com.redhat.devtools.intellij:intellij-common-ui-test-library:0.4.2")
// And now for some serious HACK!!!
// Starting with 2023.1, all gradle tests fail importing projects with a:
// com.intellij.openapi.externalSystem.model.ExternalSystemException: Unable to load class 'org.codehaus.plexus.logging.Logger'
// Hence adding a jar containing the missing class, to the test classpath
// The version matches the jar found in the IJ version used to compile the project
// This is so wrong/ridiculous!
testImplementation("org.eclipse.sisu:org.eclipse.sisu.plexus:0.3.4")
testImplementation("org.assertj:assertj-core:3.19.0")
}
// Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+.
kotlin {
jvmToolchain {
languageVersion = JavaLanguageVersion.of(17)
vendor = JvmVendorSpec.JETBRAINS
}
}
// Configure Gradle IntelliJ Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
intellij {
pluginName = properties("pluginName")
version = properties("platformVersion")
type = properties("platformType")
updateSinceUntilBuild = false
val platformPlugins = ArrayList<Any>()
val localLsp4ij = file("../lsp4ij/build/idea-sandbox/plugins/LSP4IJ").absoluteFile
if (localLsp4ij.isDirectory) {
// In case Gradle fails to build because it can't find some missing jar, try deleting
// ~/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/unzipped.com.jetbrains.plugins/com.redhat.devtools.lsp4ij*
platformPlugins.add(localLsp4ij)
} else {
// When running on CI or when there's no local lsp4ij
val latestLsp4ijNightlyVersion = fetchLatestLsp4ijNightlyVersion()
platformPlugins.add("com.redhat.devtools.lsp4ij:$latestLsp4ijNightlyVersion@nightly")
}
//Uses `platformPlugins` property from the gradle.properties file.
platformPlugins.addAll(properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) }.get())
println("platformPlugins: $platformPlugins")
plugins = platformPlugins
}
configurations {
runtimeClasspath {
exclude(group = "org.slf4j", module = "slf4j-api")
}
testImplementation {
isCanBeResolved = true
}
}
testlogger {
theme = ThemeType.STANDARD
showExceptions = true
showStackTraces = true
showFullStackTraces = false
showCauses = true
slowThreshold = 2000
showSummary = true
showSimpleNames = false
showPassed = true
showSkipped = true
showFailed = true
showOnlySlow = false
showStandardStreams = false
showPassedStandardStreams = true
showSkippedStandardStreams = true
showFailedStandardStreams = true
logLevel = LogLevel.LIFECYCLE
}
// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
changelog {
groups.empty()
repositoryUrl = properties("pluginRepositoryUrl")
}
tasks.withType<Test> {
environment("GRADLE_RELEASE_REPOSITORY","https://services.gradle.org/distributions")
systemProperty("idea.log.leaked.projects.in.tests", "false")
systemProperty( "idea.maven.test.mirror", "https://repo1.maven.org/maven2")
systemProperty( "com.redhat.devtools.intellij.telemetry.mode", "disabled")
systemProperty("java.awt.headless","true")
}
tasks.withType<Copy> {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
tasks.register<Test>("integrationTest") {
useJUnitPlatform()
description = "Runs the integration tests."
group = "verification"
testClassesDirs = sourceSets["integrationTest"].output.classesDirs
classpath = sourceSets["integrationTest"].runtimeClasspath
outputs.upToDateWhen { false }
mustRunAfter(tasks["test"])
}
tasks.register<Copy>("copyDeps") {
val serverDir = layout.buildDirectory.dir("server/server")
from(lsp)
into(serverDir)
rename("^(.*)(-[0-9]+.[0-9]+.[0-9]+(-SNAPSHOT)?)(.*)$", "$1$4")
doLast {
val destinationDir = serverDir.get().asFile
val numFilesCopied = destinationDir.listFiles()?.size ?: 0
logger.quiet("Copied $numFilesCopied JARs from lsp configuration to ${destinationDir}.")
}
}
tasks {
wrapper {
gradleVersion = properties("gradleVersion").get()
}
runPluginVerifier {
failureLevel = listOf(INVALID_PLUGIN, COMPATIBILITY_PROBLEMS, MISSING_DEPENDENCIES )
verificationReportsFormats = listOf(MARKDOWN, HTML)
}
patchPluginXml {
version = properties("pluginVersion")
sinceBuild = properties("pluginSinceBuild")
untilBuild = properties("pluginUntilBuild")
// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
pluginDescription = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"
with(it.lines()) {
if (!containsAll(listOf(start, end))) {
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
}
subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML)
}
}
//TODO inject changelog into plugin.xml change-notes
}
runIde {
systemProperties["com.redhat.devtools.intellij.telemetry.mode"] = "disabled"
}
// Configure UI tests plugin
// Read more: https://github.com/JetBrains/intellij-ui-test-robot
runIdeForUiTests {
systemProperty("robot-server.port", System.getProperty("robot-server.port"))
systemProperty("ide.mac.message.dialogs.as.sheets", "false")
systemProperty("jb.privacy.policy.text", "<!--999.999-->")
systemProperty("jb.consents.confirmation.enabled", "false")
}
prepareSandbox {
dependsOn("copyDeps")
}
jacocoTestReport {
reports {
xml.required = true
html.required = true
}
}
signPlugin {
certificateChain = environment("CERTIFICATE_CHAIN")
privateKey = environment("PRIVATE_KEY")
password = environment("PRIVATE_KEY_PASSWORD")
}
publishPlugin {
//dependsOn("patchChangelog") // TODO generate changelog
token = environment("PUBLISH_TOKEN")
channels = properties("channel").map { listOf(it) }
}
check {
dependsOn(jacocoTestReport)
}
}
fun fetchLatestLsp4ijNightlyVersion(): String {
val client = HttpClient.newBuilder().build();
var onlineVersion = ""
try {
val request: HttpRequest = HttpRequest.newBuilder()
.uri(URI("https://plugins.jetbrains.com/api/plugins/23257/updates?channel=nightly&size=1"))
.GET()
.timeout(Duration.of(10, ChronoUnit.SECONDS))
.build()
val response = client.send(request, HttpResponse.BodyHandlers.ofString());
val pattern = Pattern.compile("\"version\":\"([^\"]+)\"")
val matcher = pattern.matcher(response.body())
if (matcher.find()) {
onlineVersion = matcher.group(1)
println("Latest approved nightly build: $onlineVersion")
}
} catch (e:Exception) {
println("Failed to fetch LSP4IJ nightly build version: ${e.message}")
}
val minVersion = "0.0.1-20231213-012910"
return if (minVersion < onlineVersion) onlineVersion else minVersion
}