Skip to content

Commit 6a2ae39

Browse files
authored
Add build skeleton for Q subplugin (#4154)
1 parent 29d70d7 commit 6a2ae39

File tree

21 files changed

+226
-44
lines changed

21 files changed

+226
-44
lines changed

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

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,6 @@ configurations {
5858
exclude(group = "software.amazon.awssdk", module = "netty-nio-client")
5959
}
6060

61-
// TODO: https://github.com/gradle/gradle/issues/15383
62-
val versionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs")
63-
dependencies {
64-
testImplementation(platform(versionCatalog.findLibrary("junit5-bom").get()))
65-
testImplementation(versionCatalog.findLibrary("junit5-jupiterApi").get())
66-
67-
testRuntimeOnly(versionCatalog.findLibrary("junit5-jupiterEngine").get())
68-
testRuntimeOnly(versionCatalog.findLibrary("junit5-jupiterVintage").get())
69-
}
70-
7161
all {
7262
if (name.startsWith("detekt")) {
7363
return@all
@@ -94,7 +84,9 @@ tasks.processResources {
9484

9585
// Run after the project has been evaluated so that the extension (intellijToolkit) has been configured
9686
intellij {
97-
pluginName.set("aws-toolkit-jetbrains")
87+
// find the name of first subproject depth, or root if not applied to a subproject hierarchy
88+
val projectName = generateSequence(project) { it.parent }.first { it.depth <= 1 }.name
89+
pluginName.convention(projectName)
9890

9991
localPath.set(toolkitIntelliJ.localPath())
10092
version.set(toolkitIntelliJ.version())
@@ -106,7 +98,8 @@ intellij {
10698
}
10799

108100
tasks.jar {
109-
archiveBaseName.set(toolkitIntelliJ.ideFlavor.map { "aws-toolkit-jetbrains-$it" })
101+
// :plugin-toolkit:jetbrains-community results in: --plugin-toolkit-jetbrains-community-IC-<version>.jar
102+
archiveBaseName.set(toolkitIntelliJ.ideFlavor.map { "${project.buildTreePath.replace(':', '-')}-$it" })
110103
}
111104

112105
tasks.withType<PatchPluginXmlTask>().all {
@@ -148,14 +141,10 @@ tasks.withType<Test>().all {
148141
systemProperty("log.dir", intellij.sandboxDir.map { "$it-test/logs" }.get())
149142
systemProperty("testDataPath", project.rootDir.resolve("testdata").absolutePath)
150143
val jetbrainsCoreTestResources = project(":plugin-toolkit:jetbrains-core").projectDir.resolve("tst-resources")
151-
// FIX_WHEN_MIN_IS_221: log4j 1.2 removed in 221
152-
systemProperty("log4j.configuration", jetbrainsCoreTestResources.resolve("log4j.xml"))
153144
systemProperty("idea.log.config.properties.file", jetbrainsCoreTestResources.resolve("toolkit-test-log.properties"))
154145
systemProperty("org.gradle.project.ideProfileName", ideProfile.name)
155146

156147
jvmArgs(openedPackages)
157-
158-
useJUnitPlatform()
159148
}
160149

161150
tasks.withType<JavaExec> {

buildSrc/src/main/kotlin/toolkit-kotlin-conventions.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ plugins {
1616
// TODO: https://github.com/gradle/gradle/issues/15383
1717
val versionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs")
1818
dependencies {
19+
// kotlin/kotlin-coroutines might not be necessary if we're in an intellij-plugin-based module
20+
// - The dependency on the Kotlin Standard Library (stdlib) is automatically added when using the Gradle Kotlin plugin and may conflict with the version provided with the IntelliJ Platform, see: https://jb.gg/intellij-platform-kotlin-stdlib
21+
//- The Kotlin Coroutines library should not be added explicitly to the project as it is already provided with the IntelliJ Platform.
1922
implementation(versionCatalog.findBundle("kotlin").get())
2023
implementation(versionCatalog.findLibrary("kotlin-coroutines").get())
2124

buildSrc/src/main/kotlin/toolkit-testing.gradle.kts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ dependencies {
1616
testImplementation(versionCatalog.findBundle("mockito").get())
1717
testImplementation(versionCatalog.findLibrary("assertj").get())
1818

19-
// Don't add a test framework by default since we use junit4, junit5, and testng depending on project
19+
// Everything uses junit4/5 except rider, which uses TestNG
20+
testImplementation(platform(versionCatalog.findLibrary("junit5-bom").get()))
21+
testImplementation(versionCatalog.findLibrary("junit5-jupiterApi").get())
22+
23+
testRuntimeOnly(versionCatalog.findLibrary("junit5-jupiterEngine").get())
24+
testRuntimeOnly(versionCatalog.findLibrary("junit5-jupiterVintage").get())
2025
}
2126

2227
jacoco {
@@ -45,6 +50,8 @@ artifacts {
4550
}
4651

4752
tasks.withType<Test>().all {
53+
useJUnitPlatform()
54+
4855
ciOnly {
4956
retry {
5057
failOnPassedAfterRetry.set(false)

plugins/amazonq/build.gradle.kts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import software.aws.toolkits.gradle.intellij.IdeFlavor
5+
import software.aws.toolkits.gradle.intellij.IdeVersions
6+
7+
plugins {
8+
id("org.jetbrains.intellij")
9+
}
10+
11+
val ideProfile = IdeVersions.ideProfile(project)
12+
13+
val toolkitVersion: String by project
14+
val publishToken: String by project
15+
val publishChannel: String by project
16+
17+
intellij {
18+
version.set(ideProfile.community.version())
19+
localPath.set(ideProfile.community.localPath())
20+
21+
updateSinceUntilBuild.set(false)
22+
instrumentCode.set(false)
23+
}
24+
25+
dependencies {
26+
implementation(project(":plugin-amazonq:shared"))
27+
implementation(project(":plugin-amazonq:codewhisperer"))
28+
implementation(project(":plugin-amazonq:mynah-ui"))
29+
}
30+
31+
configurations {
32+
// Make sure we exclude stuff we either A) ships with IDE, B) we don't use to cut down on size
33+
runtimeClasspath {
34+
exclude(group = "org.slf4j")
35+
exclude(group = "org.jetbrains.kotlin")
36+
exclude(group = "org.jetbrains.kotlinx")
37+
}
38+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
plugins {
5+
id("java")
6+
}
7+
8+
dependencies {
9+
implementation(project(":plugin-amazonq:codewhisperer:jetbrains-community", "instrumentedJar"))
10+
implementation(project(":plugin-amazonq:codewhisperer:jetbrains-ultimate", "instrumentedJar"))
11+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import software.aws.toolkits.gradle.intellij.IdeFlavor
5+
6+
plugins {
7+
id("toolkit-intellij-subplugin")
8+
}
9+
10+
intellijToolkit {
11+
ideFlavor.set(IdeFlavor.IC)
12+
}
13+
14+
dependencies {
15+
compileOnly(project(":plugin-amazonq:shared:jetbrains-community"))
16+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!-- Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -->
2+
<!-- SPDX-License-Identifier: Apache-2.0 -->
3+
4+
<idea-plugin>
5+
<actions>
6+
<action class="Hello" id="q.hello" />
7+
</actions>
8+
</idea-plugin>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import com.intellij.openapi.actionSystem.AnAction
5+
import com.intellij.openapi.actionSystem.AnActionEvent
6+
import com.intellij.openapi.project.DumbAware
7+
import com.intellij.openapi.ui.MessageDialogBuilder
8+
import software.aws.toolkits.resources.AmazonQBundle
9+
10+
class Hello : AnAction(AmazonQBundle.message("q.hello")), DumbAware {
11+
override fun actionPerformed(e: AnActionEvent) {
12+
MessageDialogBuilder.okCancel("title", AmazonQBundle.message("q.hello"))
13+
.ask(e.project)
14+
}
15+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import software.aws.toolkits.gradle.intellij.IdeFlavor
5+
6+
plugins {
7+
id("toolkit-intellij-subplugin")
8+
}
9+
10+
intellijToolkit {
11+
ideFlavor.set(IdeFlavor.IU)
12+
}
13+
14+
dependencies {
15+
compileOnly(project(":plugin-amazonq:codewhisperer:jetbrains-community"))
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
plugins {
5+
id("java")
6+
}
7+
8+
dependencies {
9+
implementation(project(":plugin-amazonq:shared:jetbrains-community", "instrumentedJar"))
10+
11+
// delete when fully split
12+
implementation(project(":plugin-amazonq:shared:jetbrains-ultimate", "instrumentedJar"))
13+
}

0 commit comments

Comments
 (0)