Skip to content

Commit 3d0a368

Browse files
authored
build: migrate Core to a shadow JAR dependency (#6112)
1 parent bea1e50 commit 3d0a368

File tree

27 files changed

+113
-144
lines changed

27 files changed

+113
-144
lines changed

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ node-gradle = "7.0.2"
3131
telemetryGenerator = "1.0.338"
3232
testLogger = "4.0.0"
3333
testRetry = "1.5.10"
34+
shadow = "9.2.2"
3435
# test-only; platform provides slf4j transitively at runtime
3536
slf4j = "2.0.16"
3637
sshd = "2.13.2"
@@ -128,5 +129,6 @@ mockito = ["mockito-core", "mockito-junit-jupiter", "mockito-kotlin"]
128129
sshd = ["sshd-core", "sshd-scp", "sshd-sftp"]
129130

130131
[plugins]
132+
gradleup-shadow = { id = "com.gradleup.shadow", version.ref = "shadow" }
131133
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
132134
node-gradle = { id = "com.github.node-gradle.node", version.ref = "node-gradle" }

plugins/amazonq/build.gradle.kts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ tasks.jar {
3434
}
3535

3636
dependencies {
37-
intellijPlatform {
38-
localPlugin(project(":plugin-core"))
39-
}
40-
37+
implementation(project(path = ":plugin-core", configuration = "shadow"))
4138
implementation(project(":plugin-amazonq:chat"))
4239
implementation(project(":plugin-amazonq:codetransform"))
4340
implementation(project(":plugin-amazonq:codewhisperer"))

plugins/amazonq/chat/jetbrains-community/build.gradle.kts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ intellijToolkit {
1212
}
1313

1414
dependencies {
15-
intellijPlatform {
16-
localPlugin(project(":plugin-core"))
17-
}
15+
implementation(project(path = ":plugin-core", configuration = "shadow"))
1816

1917
implementation(project(":plugin-amazonq:shared:jetbrains-community"))
2018
// everything references codewhisperer, which is not ideal
@@ -26,3 +24,13 @@ dependencies {
2624

2725
testImplementation(testFixtures(project(":plugin-core:jetbrains-community")))
2826
}
27+
28+
// hack because our test structure currently doesn't make complete sense
29+
tasks.prepareTestSandbox {
30+
val pluginXmlJar = project(":plugin-amazonq").tasks.jar
31+
32+
dependsOn(pluginXmlJar)
33+
from(pluginXmlJar) {
34+
into(intellijPlatform.projectName.map { "$it/lib" })
35+
}
36+
}

plugins/amazonq/codetransform/jetbrains-community/build.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ intellijToolkit {
1212
}
1313

1414
dependencies {
15-
intellijPlatform {
16-
localPlugin(project(":plugin-core"))
17-
}
15+
implementation(project(path = ":plugin-core", configuration = "shadow"))
1816

1917
implementation(project(":plugin-amazonq:shared:jetbrains-community"))
2018
// hack because transform has a chat entrypoint

plugins/amazonq/codewhisperer/jetbrains-community/build.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ intellijToolkit {
1212
}
1313

1414
dependencies {
15-
intellijPlatform {
16-
localPlugin(project(":plugin-core"))
17-
}
15+
implementation(project(path = ":plugin-core", configuration = "shadow"))
1816

1917
compileOnly(project(":plugin-core:jetbrains-community"))
2018

plugins/amazonq/codewhisperer/jetbrains-ultimate/build.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ intellijToolkit {
1212
}
1313

1414
dependencies {
15-
intellijPlatform {
16-
localPlugin(project(":plugin-core"))
17-
}
15+
implementation(project(path = ":plugin-core", configuration = "shadow"))
1816

1917
compileOnly(project(":plugin-amazonq:codewhisperer:jetbrains-community"))
2018
compileOnly(project(":plugin-amazonq:shared:jetbrains-ultimate"))

plugins/amazonq/shared/jetbrains-community/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ intellijToolkit {
1414

1515
dependencies {
1616
intellijPlatform {
17-
localPlugin(project(":plugin-core"))
1817
platformDependency(Coordinates(groupId = "com.jetbrains.intellij.rd", artifactId = "rd-platform"))
1918
}
2019

20+
implementation(project(path = ":plugin-core", configuration = "shadow"))
21+
2122
compileOnlyApi(project(":plugin-core:jetbrains-community"))
2223

2324
// CodeWhispererTelemetryService uses a CircularFifoQueue

plugins/amazonq/src/main/resources/META-INF/plugin.xml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
<!-- SPDX-License-Identifier: Apache-2.0 -->
33

44
<idea-plugin xmlns:xi="http://www.w3.org/2001/XInclude" require-restart="true">
5+
<xi:include href="/META-INF/module-core.xml" />
6+
<xi:include href="/META-INF/aws.toolkit.core.xml" />
7+
58
<id>amazon.q</id>
69
<name>Amazon Q</name>
710
<description><![CDATA[
@@ -60,7 +63,8 @@
6063
<depends optional="true">org.jetbrains.idea.maven</depends>
6164
<resource-bundle>software.aws.toolkits.resources.MessagesBundle</resource-bundle>
6265

63-
<depends>aws.toolkit.core</depends>
66+
<incompatible-with>aws.toolkit.core</incompatible-with>
67+
6468
<depends>com.intellij.modules.lang</depends>
6569

6670
<depends optional="true" config-file="amazonq-ext-codewithme.xml">com.jetbrains.codeWithMe</depends>
@@ -104,4 +108,15 @@
104108
<xi:include href="/META-INF/change-notes.xml" xpointer="xpointer(/idea-plugin/*)">
105109
<xi:fallback/>
106110
</xi:include>
111+
112+
<extensions defaultExtensionNs="com.intellij">
113+
<!-- each plugin needs its own instance of these -->
114+
<applicationService serviceImplementation="migration.software.aws.toolkits.jetbrains.core.coroutines.PluginCoroutineScopeTracker"/>
115+
<projectService serviceImplementation="migration.software.aws.toolkits.jetbrains.core.coroutines.PluginCoroutineScopeTracker"/>
116+
<postStartupActivity implementation = "software.aws.toolkits.jetbrains.core.notifications.NotificationServiceInitializer"/>
117+
<postStartupActivity implementation="software.aws.toolkits.jetbrains.services.telemetry.AwsToolkitStartupMetrics"/>
118+
</extensions>
119+
<projectListeners>
120+
<listener class="software.aws.toolkits.jetbrains.services.telemetry.OpenedFileTypesMetricsListener" topic="com.intellij.openapi.fileEditor.FileEditorManagerListener"/>
121+
</projectListeners>
107122
</idea-plugin>

plugins/core/build.gradle.kts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
plugins {
5-
id("toolkit-publishing-conventions")
6-
id("toolkit-publish-root-conventions")
75
id("toolkit-jvm-conventions")
86
id("toolkit-testing")
7+
alias(libs.plugins.gradleup.shadow)
98
}
109

1110
dependencies {
@@ -19,9 +18,34 @@ dependencies {
1918
implementation(libs.slf4j.jdk14)
2019
}
2120

21+
configurations {
22+
configureEach {
23+
// IDE provides netty
24+
exclude("io.netty")
25+
}
26+
27+
// Make sure we exclude stuff we either A) ships with IDE, B) we don't use to cut down on size
28+
runtimeClasspath {
29+
exclude(group = "com.google.code.gson")
30+
exclude(group = "org.jetbrains.kotlin")
31+
exclude(group = "org.jetbrains.kotlinx")
32+
}
33+
}
34+
2235
tasks.check {
2336
val coreProject = project(":plugin-core").subprojects
2437
coreProject.forEach {
2538
dependsOn(":plugin-core:${it.name}:check")
2639
}
2740
}
41+
42+
tasks.shadowJar {
43+
archiveBaseName.set("plugin-core-shadow")
44+
archiveVersion.set(rootProject.version.toString())
45+
archiveClassifier.set("")
46+
47+
exclude("/META-INF/plugin.xml")
48+
49+
configurations = project.configurations.runtimeClasspath.map { listOf(it) }
50+
destinationDirectory.set(layout.buildDirectory.dir("libs"))
51+
}

0 commit comments

Comments
 (0)