-
Notifications
You must be signed in to change notification settings - Fork 287
Expand file tree
/
Copy pathtoolkit-intellij-subplugin.gradle.kts
More file actions
170 lines (143 loc) · 6.96 KB
/
toolkit-intellij-subplugin.gradle.kts
File metadata and controls
170 lines (143 loc) · 6.96 KB
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
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import org.jetbrains.intellij.platform.gradle.tasks.PrepareSandboxTask
import software.aws.toolkits.gradle.findFolders
import software.aws.toolkits.gradle.intellij.IdeFlavor
import software.aws.toolkits.gradle.intellij.IdeVersions
import software.aws.toolkits.gradle.intellij.toolkitIntelliJ
val ideProfile = IdeVersions.ideProfile(project)
plugins {
id("toolkit-intellij-plugin")
id("toolkit-kotlin-conventions")
id("toolkit-testing")
}
// TODO: https://github.com/gradle/gradle/issues/15383
val versionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs")
// Add our source sets per IDE profile version (i.e. src-211)
sourceSets {
main {
java.srcDirs(findFolders(project, "src", ideProfile))
resources.srcDirs(findFolders(project, "resources", ideProfile))
}
test {
java.srcDirs(findFolders(project, "tst", ideProfile))
resources.srcDirs(findFolders(project, "tst-resources", ideProfile))
}
}
configurations {
runtimeClasspath {
// IDE provides Kotlin
exclude(group = "org.jetbrains.kotlin")
exclude(group = "org.jetbrains.kotlinx")
}
configureEach {
// IDE provides netty
exclude("io.netty")
if (name.startsWith("detekt")) {
return@configureEach
}
// Exclude dependencies that ship with iDE
exclude(group = "org.slf4j")
if (!name.startsWith("kotlinCompiler") && !name.startsWith("generateModels") && !name.startsWith("rdGen")) {
// we want kotlinx-coroutines-debug and kotlinx-coroutines-test
exclude(group = "org.jetbrains.kotlinx", "kotlinx-coroutines-core-jvm")
exclude(group = "org.jetbrains.kotlinx", "kotlinx-coroutines-core")
}
resolutionStrategy.eachDependency {
if (requested.group == "org.jetbrains.kotlinx" && requested.name.startsWith("kotlinx-coroutines")) {
useVersion(versionCatalog.findVersion("kotlinCoroutines").get().toString())
because("resolve kotlinx-coroutines version conflicts in favor of local version catalog")
}
if (requested.group == "org.jetbrains.kotlin" && requested.name.startsWith("kotlin")) {
useVersion(versionCatalog.findVersion("kotlin").get().toString())
because("resolve kotlin version conflicts in favor of local version catalog")
}
// https://nvd.nist.gov/vuln/detail/cve-2022-25647
if (requested.group == "com.google.code.gson" && requested.name == "gson") {
useVersion("2.11.0")
because("CVE-2022-25647 requires Gson >= 2.8.9")
}
}
}
}
tasks.processResources {
// needed because both rider and ultimate include plugin-datagrip.xml which we are fine with
duplicatesStrategy = DuplicatesStrategy.WARN
}
tasks.processTestResources {
// TODO how can we remove this
duplicatesStrategy = DuplicatesStrategy.WARN
}
// Run after the project has been evaluated so that the extension (intellijToolkit) has been configured
intellijPlatform {
// find the name of first subproject depth, or root if not applied to a subproject hierarchy
projectName.convention(generateSequence(project) { it.parent }.first { it.depth <= 1 }.name)
instrumentCode = true
}
dependencies {
intellijPlatform {
val version = toolkitIntelliJ.version()
// annoying resolution issue that we don't want to bother fixing
if (!project.name.contains("jetbrains-gateway")) {
val type = toolkitIntelliJ.ideFlavor.map { flavor ->
// Starting with 2025.3, IntelliJ IDEA is unified (no separate Community edition)
if ((version.get().startsWith("2025.3") || version.get().startsWith("2026.")) && flavor == IdeFlavor.IC) {
IntelliJPlatformType.IntellijIdeaUltimate
} else {
IntelliJPlatformType.fromCode(flavor.toString())
}
}
create(type, version, useInstaller = false)
} else {
create(IntelliJPlatformType.Gateway, version)
// Gateway 2026.1 product-info.json has layout entries without "classPath".
// intellij-plugin-structure crashes on these (ProductModuleV2.classPath is non-null).
// Bug exists on master: https://github.com/JetBrains/intellij-plugin-verifier
// Force-resolve IDE, patch product-info.json, then let bundledPlugins proceed.
afterEvaluate {
configurations.findByName("intellijPlatformDependency")?.resolve()
software.aws.toolkits.gradle.intellij.ProductInfoPatcher.patchGatewayProductInfo(
gradle.gradleUserHomeDir
)
}
}
bundledPlugins(toolkitIntelliJ.productProfile().map { it.bundledPlugins })
plugins(toolkitIntelliJ.productProfile().map { it.marketplacePlugins })
// OAuth modules split in 2025.3+ - must be explicitly bundled
val versionStr = version.get()
if (versionStr.contains("253") || versionStr.startsWith("2025.3") ||
versionStr.startsWith("2026.")) {
bundledModule("intellij.platform.collaborationTools")
bundledModule("intellij.platform.collaborationTools.auth.base")
bundledModule("intellij.platform.collaborationTools.auth")
}
testFramework(TestFrameworkType.Plugin.Java)
testFramework(TestFrameworkType.Platform)
testFramework(TestFrameworkType.JUnit5)
}
}
// https://github.com/JetBrains/intellij-platform-gradle-plugin/issues/1844
tasks.withType<PrepareSandboxTask>().configureEach {
disabledPlugins.addAll(
"com.intellij.swagger",
"org.jetbrains.plugins.kotlin.jupyter",
)
}
tasks.jar {
// :plugin-toolkit:jetbrains-community results in: --plugin-toolkit-jetbrains-community-IC-<version>.jar
archiveBaseName.set(toolkitIntelliJ.ideFlavor.map { "${project.buildTreePath.replace(':', '-')}-$it" })
}
tasks.withType<Test>().configureEach {
// conflict with Docker logging impl; so bypass service loader
systemProperty("slf4j.provider", "org.slf4j.jul.JULServiceProvider")
systemProperty("log.dir", intellijPlatform.sandboxContainer.map { "$it-test/logs" }.get())
systemProperty("testDataPath", project.rootDir.resolve("testdata").absolutePath)
val jetbrainsCoreTestResources = project(":plugin-toolkit:jetbrains-core").projectDir.resolve("tst-resources")
systemProperty("idea.log.config.properties.file", jetbrainsCoreTestResources.resolve("toolkit-test-log.properties"))
systemProperty("org.gradle.project.ideProfileName", ideProfile.name)
}
tasks.withType<JavaExec>().configureEach {
systemProperty("aws.toolkits.enableTelemetry", false)
}