Skip to content

Commit 4af1aa5

Browse files
authored
fix(gateway): Enable Gateway plugin build for 2026.1 (#6342)
1 parent 284803c commit 4af1aa5

File tree

4 files changed

+69
-2
lines changed

4 files changed

+69
-2
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package software.aws.toolkits.gradle.intellij
5+
6+
import java.io.File
7+
8+
/**
9+
* Gateway 2026.1 product-info.json has moduleV2/productModuleV2 layout entries without
10+
* "classPath". intellij-plugin-structure declares ProductModuleV2.classPath as non-null
11+
* Kotlin parameter, so Jackson throws NPE during deserialization.
12+
*
13+
* Bug exists on master: https://github.com/JetBrains/intellij-plugin-verifier
14+
* (intellij-plugin-structure/structure-intellij/.../ProductInfo.kt)
15+
*
16+
* Patches cached product-info.json to add empty classPath arrays where missing.
17+
*/
18+
object ProductInfoPatcher {
19+
private val MISSING_CLASSPATH = Regex(
20+
"""(?s)"kind"\s*:\s*"(moduleV2|productModuleV2)"\s*\}"""
21+
)
22+
23+
fun patchGatewayProductInfo(gradleUserHome: File) {
24+
val caches = gradleUserHome.resolve("caches")
25+
if (!caches.isDirectory) return
26+
27+
caches.listFiles()
28+
?.filter { it.isDirectory && it.name.matches(Regex("\\d+\\.\\d+")) }
29+
?.forEach { versionDir ->
30+
val transformsDir = versionDir.resolve("transforms")
31+
if (!transformsDir.isDirectory) return@forEach
32+
transformsDir.listFiles()?.forEach inner@{ transformDir ->
33+
val transformed = transformDir.resolve("transformed")
34+
if (!transformed.isDirectory) return@inner
35+
transformed.listFiles()
36+
?.filter { it.name.startsWith("JetBrainsGateway") }
37+
?.forEach { gatewayDir ->
38+
patchFile(gatewayDir.resolve("product-info.json"))
39+
}
40+
}
41+
}
42+
}
43+
44+
private fun patchFile(productInfo: File) {
45+
if (!productInfo.isFile) return
46+
val content = productInfo.readText()
47+
val patched = MISSING_CLASSPATH.replace(content) {
48+
"\"kind\": \"${it.groupValues[1]}\",\n \"classPath\": []\n }"
49+
}
50+
if (patched != content) {
51+
productInfo.writeText(patched)
52+
}
53+
}
54+
}

buildSrc/src/main/kotlin/toolkit-intellij-subplugin.gradle.kts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,17 @@ dependencies {
110110
create(type, version, useInstaller = false)
111111
} else {
112112
create(IntelliJPlatformType.Gateway, version)
113+
114+
// Gateway 2026.1 product-info.json has layout entries without "classPath".
115+
// intellij-plugin-structure crashes on these (ProductModuleV2.classPath is non-null).
116+
// Bug exists on master: https://github.com/JetBrains/intellij-plugin-verifier
117+
// Force-resolve IDE, patch product-info.json, then let bundledPlugins proceed.
118+
afterEvaluate {
119+
configurations.findByName("intellijPlatformDependency")?.resolve()
120+
software.aws.toolkits.gradle.intellij.ProductInfoPatcher.patchGatewayProductInfo(
121+
gradle.gradleUserHomeDir
122+
)
123+
}
113124
}
114125

115126
bundledPlugins(toolkitIntelliJ.productProfile().map { it.bundledPlugins })

plugins/toolkit/jetbrains-core/resources/META-INF/inactive/plugin-gateway.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
<incompatible-with>com.intellij.modules.python</incompatible-with>
1515
<incompatible-with>com.intellij.java</incompatible-with>
1616

17-
<xi:include href="/META-INF/module-core.xml" />
17+
<xi:include href="/META-INF/module-core.xml">
18+
<xi:fallback/>
19+
</xi:include>
1820

1921
<extensions defaultExtensionNs="com.intellij">
2022
<applicationService serviceInterface="software.aws.toolkit.jetbrains.core.credentials.ToolkitConnectionManager"

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ file("plugins").listFiles()?.forEach root@ {
170170
if (it.name == "jetbrains-gateway") {
171171
when (providers.gradleProperty("ideProfileName").get()) {
172172
// buildSrc is evaluated after settings so we can't key off of IdeVersions.kt
173-
"2025.1", "2025.2", "2026.1" -> {
173+
"2025.1", "2025.2" -> {
174174
return@forEach
175175
}
176176
}

0 commit comments

Comments
 (0)