generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.gradle.kts
380 lines (304 loc) · 14.4 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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
import common.BuildProfiles
import common.BuildProfiles.greaterThan
import common.buildVersion
import common.currentProfile
import common.dynamicPlatformType
import common.platformVersion
import common.properties
import common.useBinaryInstaller
import common.withCurrentProfile
import org.apache.tools.ant.filters.ReplaceTokens
import org.jetbrains.changelog.date
import org.jetbrains.changelog.exceptions.MissingVersionException
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
import org.jetbrains.intellij.platform.gradle.models.ProductRelease
import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask
fun properties(key: String) = properties(key, project)
plugins {
id("semantic-version")
id("plugin-project")
id("org.jetbrains.changelog") version "2.2.0"
id("org.jetbrains.qodana") version "0.1.13"
id("org.jetbrains.kotlinx.kover") version "0.7.5"
}
//the platformType determines which platform we build with, it may be IC,IU,PC,PY,RD.
//it is a good way for us to test that we don't have leaking usages of classes that exist in one platform
//but don't exist in another.
//this module should be compatible with all IDEs, and thus it should build with IC,IU,RD with no issues.
//the platformType is determined dynamically based on other property,
// we have for example buildWithRider,buildWIthUltimate.
//the other modules either also build with dynamic platform type or always build with the same type.
val platformType: IntelliJPlatformType by extra(dynamicPlatformType(project))
tasks.register("printCurrentProfileBuildVersion") {
doLast {
println("build-version=${project.buildVersion()}")
}
}
//this project depends on rider dotnet artifacts. this will force the dotnet build before packaging.
val riderDotNetObjects: Configuration by configurations.creating {
isCanBeConsumed = false
isCanBeResolved = true
}
dependencies {
//modules that are not plugin modules should be added as implementation.
//plugin modules, modules with org.jetbrains.intellij.platform.module, should be added as
// pluginModule in the intellijPlatform dependencies extension.
implementation(libs.commons.lang3)
implementation(libs.freemarker)
implementation(project(":model"))
implementation(project(":analytics-provider"))
riderDotNetObjects(
project(
mapOf(
"path" to ":rider",
"configuration" to "riderDotNetObjects"
)
)
)
intellijPlatform {
//this module is the main plugin module and should not depend on any intellij bundled plugin, the code here should
// be common to all IDEs. specific modules depend on specific plugins, for example the jvm-common
// module depends on java and kotlin, ide-common depends on git, python depends on python plugin etc.
val version = project.platformVersion()
//the intellij product. we use the create method because it may be Idea,Rider,Pycharm etc.
create(platformType, version, project.useBinaryInstaller())
pluginModule(implementation(project(":ide-common")))
pluginModule(implementation(project(":jvm-common")))
pluginModule(implementation(project(":gradle-support")))
pluginModule(implementation(project(":maven-support")))
pluginModule(implementation(project(":rider")))
pluginModule(implementation(project(":kotlin")))
pluginVerifier()
zipSigner()
//todo: this is a workaround for plugin 2.1.0, this module should be bundled.
// check in next version if it is still necessary.
// https://jetbrains-platform.slack.com/archives/C05C80200LS/p1730794028550679
if (project.currentProfile().profile.greaterThan(BuildProfiles.Profile.p241)) {
bundledModule("intellij.platform.collaborationTools")
}
}
}
configurations.getByName("runtimeClasspath") {
//make sure we never package kotlin-stdlib-jdk8 or kotlin-stdlib-jdk7 because it is supplied by the IDE.
//see more in
//https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library
//settings.gradle.kts
exclude("org.jetbrains.kotlin", "kotlin-stdlib")
exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk8")
exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk7")
}
// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
changelog {
//change log needs the base version,not the build version
val versionToUse = common.semanticversion.getSemanticVersion(project)
version.set(versionToUse)
path.set("${project.projectDir}/CHANGELOG.md")
groups.set(listOf("Added", "Changed", "Deprecated", "Removed", "Fixed", "Security"))
header.set(provider { "[${versionToUse}] - ${date()}" })
keepUnreleasedSection.set(false)
}
// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin
qodana {
cachePath.set(projectDir.resolve(".qodana").canonicalPath)
reportPath.set(projectDir.resolve("build/reports/inspections").canonicalPath)
saveReport.set(true)
showReport.set(System.getenv("QODANA_SHOW_REPORT")?.toBoolean() ?: false)
}
intellijPlatform {
pluginConfiguration {
id = "org.digma.intellij"
name = properties("pluginName")
version = project.buildVersion()
description = layout.projectDirectory.file("PLUGIN-DESCRIPTION.md").asFile.readText()
val latestChangelog = try {
changelog.getUnreleased()
} catch (_: MissingVersionException) {
changelog.getLatest()
}
changeNotes.set(provider {
changelog.renderItem(
latestChangelog
.withHeader(false)
.withEmptySections(false),
org.jetbrains.changelog.Changelog.OutputType.HTML
)
})
ideaVersion {
sinceBuild = project.currentProfile().pluginSinceBuild
untilBuild = project.currentProfile().pluginUntilBuild
}
vendor {
name = "Digma.ai"
email = "[email protected]"
url = "https://digma.ai/"
}
}
//todo: add a publish workflow for alpha,beta etc.
//if the build version may contain the channel like 2.0.342+241-alpha,
// we can do that instead of just default:
// channels = listOf(project.buildVersion().split('-').getOrElse(1) { "default" }.split('.').first())
// but we don't support that yet
if (System.getenv("PUBLISH_TOKEN") != null) {
publishing {
token = System.getenv("PUBLISH_TOKEN").trim()
channels = listOf("default")
ideServices = false
hidden = false
}
}
if (System.getenv("DIGMA_JB_PRIVATE_KEY_PASSWORD") != null) {
signing {
certificateChain = System.getenv("DIGMA_JB_CERTIFICATE_CHAIN_FILE").trimIndent()
privateKey = System.getenv("DIGMA_JB_PRIVATE_KEY_FILE").trimIndent()
password = System.getenv("DIGMA_JB_PRIVATE_KEY_PASSWORD").trim()
}
}
//todo: run plugin verifier for resharper: https://blog.jetbrains.com/dotnet/2023/05/26/the-api-verifier/
pluginVerification {
//our plugin id is "org.digma.intellij", lately jetbrains added a check that
// plugin id doesn't contain the word intellij and treats it as error. so we need
// '-mute TemplateWordInPluginId' to silence this error.
freeArgs = listOf("-mute", "TemplateWordInPluginId")
ides {
//use the same platformType and version as in intellijPlatform dependencies
//Note: recommended() doesn't work well, sometimes tries to resolve a wrong IDE and fails in GitHub
withCurrentProfile { buildProfile ->
//ide doesn't work with EAP that needs to be downloaded from maven and not CDN
//there is a feature request: https://github.com/JetBrains/intellij-platform-gradle-plugin/issues/1715
//ide(platformType, buildProfile.platformVersion)
//use recommended() and hope it doesn't fail too much because sometimes it does fail for unknown reasons
recommended()
val channel = if (buildProfile.isEAP) {
ProductRelease.Channel.EAP
} else {
ProductRelease.Channel.RELEASE
}
select {
types =
listOf(IntelliJPlatformType.IntellijIdeaCommunity, IntelliJPlatformType.IntellijIdeaUltimate)
channels = listOf(channel)
sinceBuild = project.currentProfile().pluginSinceBuild
untilBuild = project.currentProfile().pluginUntilBuild
}
}
}
subsystemsToCheck = VerifyPluginTask.Subsystems.WITHOUT_ANDROID
}
}
tasks {
prepareSandbox {
//copy rider dlls to the plugin sandbox, so it is packaged in the zip
from(configurations.getByName("riderDotNetObjects")) {
into("${rootProject.name}/dotnet/")
}
//check that we have 2 files
doLast {
val files = configurations.getByName("riderDotNetObjects").files
if (files.size != 2) {
throw RuntimeException("wrong number of files in riderDotNetObjects.")
}
}
}
wrapper {
//to upgrade gradle change the version here and run:
//./gradlew wrapper --gradle-version 8.8
//check that gradle/wrapper/gradle-wrapper.properties was changed
gradleVersion = "8.11"
distributionType = Wrapper.DistributionType.ALL
distributionBase = Wrapper.PathBase.GRADLE_USER_HOME
distributionPath = "wrapper/dists"
archiveBase = Wrapper.PathBase.GRADLE_USER_HOME
archivePath = "wrapper/dists"
}
patchChangelog {
outputs.upToDateWhen { false }
doLast {
logger.lifecycle("in patchChangelog, releaseNote=$releaseNote, version=${version.get()}, inputFile=${inputFile.get()}, outputFile=${outputFile.get()}")
}
}
// Configure UI tests plugin
// Read more: https://github.com/JetBrains/intellij-ui-test-robot
// runIdeForUiTests {
// systemProperty("robot-server.port", "8082")
// systemProperty("ide.mac.message.dialogs.as.sheets", "false")
// systemProperty("jb.privacy.policy.text", "<!--999.999-->")
// systemProperty("jb.consents.confirmation.enabled", "false")
// }
val deleteLog by registering(Delete::class) {
outputs.upToDateWhen { false }
val ideFolderName = if (platformType == IntelliJPlatformType.Rider) {
"${platformType.code}-${project.currentProfile().riderVersion}"
} else {
"${platformType.code}-${project.currentProfile().platformVersion}"
}
project.layout.buildDirectory.dir("idea-sandbox/$ideFolderName/log").get().asFile.walk().forEach {
if (it.name.endsWith(".log")) {
delete(it)
}
}
}
runIde {
dependsOn(deleteLog)
//to disable the splash screen on startup because it may interrupt when debugging.
args(listOf("nosplash"))
// jvmArgs("-XX:ReservedCodeCacheSize=512M")
maxHeapSize = "4g"
systemProperties(
"idea.log.trace.categories" to "#org.digma",
"idea.log.debug.categories" to "#org.digma",
//make large idea.log because the default rotates every 10M and makes it difficult to follow messages with tail
"idea.log.limit" to "999999999",
"idea.trace.stub.index.update" to "true",
"org.digma.plugin.enable.devtools" to "true",
"kotlinx.coroutines.debug" to "",
"org.digma.plugin.report.all.errors" to "true",
"org.digma.plugin.auth.debug" to "true",
"org.digma.plugin.DigmaPathManager.dev.runIde" to "true",
//see https://kotlin.github.io/analysis-api/testing-in-k2-locally.html
"idea.kotlin.plugin.use.k2" to "true",
//"idea.ProcessCanceledException" to "disabled"
//to use a local file for digma-agent or digma extension,
// usually when developing and we want to test the plugin
//see org.digma.intellij.plugin.idea.execution.OtelAgentPathProvider
//don't forget to comment when done testing !
//"digma.agent.override.path" to "/home/shalom/workspace/digma/digma-agent/build/libs/digma-agent-2.0.4.jar"
//"digma.otel.extension.override.path" to "/home/shalom/workspace/digma/otel-java-instrumentation/agent-extension/build/libs/digma-otel-agent-extension-2.10.1.jar"
//can also change the url from where the jar is downloaded when IDE starts
//"org.digma.otel.extensionUrl" to "some url
//"org.digma.otel.digmaAgentUrl" to "some url
//custom compose file url
//"org.digma.plugin.custom.docker-compose.url" to "https://raw.githubusercontent.com/digma-ai/digma/refs/heads/0.2.73/docker/docker-compose.yml"
//ui bundle path
////"org.digma.plugin.ui.bundle.path" to "/home/shalom/Downloads/digma-ui-5.1.1.zip"
)
//to simulate external user. don't change the value it's used in UniqueGeneratedUserId
// environment(
// "devenv" to "externalUserSimulator"
// )
}
processResources {
exclude("**/webview/global-env-vars.txt")
val filesToFilter = listOf(
"webview/recent-activity/env.js",
"webview/jaeger-ui/env.js",
"webview/documentation/env.js",
"webview/dashboard/env.js",
"webview/troubleshooting/env.js",
"webview/main/env.js",
"webview/installation-wizard/env.js"
)
val globalEnvVarsFilePath = "src/main/resources/webview/global-env-vars.txt"
val globalEnvVarsFile = layout.projectDirectory.file(globalEnvVarsFilePath).asFile
inputs.file(globalEnvVarsFile.canonicalPath)
//all files are inputs so a change will trigger this task to filter again
filesToFilter.forEach {
inputs.file(layout.projectDirectory.file("src/main/resources/$it").asFile.canonicalPath)
}
val globalEnvVars = globalEnvVarsFile.readText()
val tokens = mutableMapOf<String, String>()
tokens["GLOBAL_ENV_VARS"] = globalEnvVars
filesMatching(filesToFilter) {
filter<ReplaceTokens>("tokens" to tokens)
}
}
}