diff --git a/.gitignore b/.gitignore index c095776755a..41dcb232c82 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .gradle +.intellijPlatform out/ target/ .idea diff --git a/build.gradle.kts b/build.gradle.kts index 84a37b04328..eb3b6c8cb3d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -32,7 +32,7 @@ allprojects { configurations.all { resolutionStrategy { failOnDynamicVersions() - failOnChangingVersions() +// failOnChangingVersions() } } } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 12c5caf9590..a8ffb0067fb 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -22,6 +22,7 @@ dependencies { implementation(libs.bundles.jackson) implementation(libs.commonmark) implementation(libs.gradlePlugin.detekt) + implementation(libs.gradlePlugin.ideaExt) implementation(libs.gradlePlugin.intellij) implementation(libs.gradlePlugin.kotlin) implementation(libs.gradlePlugin.testLogger) diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts index 2517d7c108d..b2c0d317cc5 100644 --- a/buildSrc/settings.gradle.kts +++ b/buildSrc/settings.gradle.kts @@ -40,8 +40,7 @@ dependencyResolutionManagement { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") content { // only allowed to pull snapshots of gradle-intellij-plugin from here - includeModule("org.jetbrains.intellij", "org.jetbrains.intellij.gradle.plugin") - includeModule("org.jetbrains.intellij.plugins", "gradle-intellij-plugin") + includeGroupByRegex("org\\.jetbrains\\.intellij\\.platform.*") } } } diff --git a/buildSrc/src/main/kotlin/software/aws/toolkits/gradle/intellij/IdeVersions.kt b/buildSrc/src/main/kotlin/software/aws/toolkits/gradle/intellij/IdeVersions.kt index 7cb2bebc46e..8012cb4ee92 100644 --- a/buildSrc/src/main/kotlin/software/aws/toolkits/gradle/intellij/IdeVersions.kt +++ b/buildSrc/src/main/kotlin/software/aws/toolkits/gradle/intellij/IdeVersions.kt @@ -11,8 +11,8 @@ import org.gradle.api.provider.ProviderFactory enum class IdeFlavor { GW, IC, IU, RD } object IdeVersions { - private val commonPlugins = arrayOf( - "vcs-git", + private val commonPlugins = listOf( + "Git4Idea", "org.jetbrains.plugins.terminal", "org.jetbrains.plugins.yaml" ) @@ -23,10 +23,12 @@ object IdeVersions { community = ProductProfile( sdkFlavor = IdeFlavor.IC, sdkVersion = "2023.2.2", - plugins = commonPlugins + listOf( - "java", + bundledPlugins = commonPlugins + listOf( + "com.intellij.java", "com.intellij.gradle", "org.jetbrains.idea.maven", + ), + marketplacePlugins = listOf( "PythonCore:232.8660.185", "Docker:232.8660.185" ) @@ -34,28 +36,23 @@ object IdeVersions { ultimate = ProductProfile( sdkFlavor = IdeFlavor.IU, sdkVersion = "2023.2.2", - plugins = commonPlugins + listOf( + bundledPlugins = commonPlugins + listOf( "JavaScript", - // Transitive dependency needed for javascript - // Can remove when https://github.com/JetBrains/gradle-intellij-plugin/issues/608 is fixed - "com.intellij.css", "JavaScriptDebugger", "com.intellij.database", "com.jetbrains.codeWithMe", + ), + marketplacePlugins = listOf( "Pythonid:232.8660.185", "org.jetbrains.plugins.go:232.8660.142", - // https://github.com/JetBrains/gradle-intellij-plugin/issues/1056 - "org.intellij.intelliLang" ) ), rider = RiderProfile( - sdkVersion = "2023.2", - plugins = commonPlugins + listOf( - "rider-plugins-appender" // Workaround for https://youtrack.jetbrains.com/issue/IDEA-179607 - ), + sdkVersion = "2023.2.5", + bundledPlugins = commonPlugins, netFrameworkTarget = "net472", rdGenVersion = "2023.2.3", - nugetVersion = "2023.2.0" + nugetVersion = "2023.2.5" ) ), Profile( @@ -63,10 +60,12 @@ object IdeVersions { community = ProductProfile( sdkFlavor = IdeFlavor.IC, sdkVersion = "2023.3", - plugins = commonPlugins + listOf( - "java", + bundledPlugins = commonPlugins + listOf( + "com.intellij.java", "com.intellij.gradle", "org.jetbrains.idea.maven", + ), + marketplacePlugins = listOf( "PythonCore:233.11799.241", "Docker:233.11799.244" ) @@ -74,25 +73,20 @@ object IdeVersions { ultimate = ProductProfile( sdkFlavor = IdeFlavor.IU, sdkVersion = "2023.3", - plugins = commonPlugins + listOf( + bundledPlugins = commonPlugins + listOf( "JavaScript", - // Transitive dependency needed for javascript - // Can remove when https://github.com/JetBrains/gradle-intellij-plugin/issues/608 is fixed - "com.intellij.css", "JavaScriptDebugger", "com.intellij.database", "com.jetbrains.codeWithMe", + ), + marketplacePlugins = listOf( "Pythonid:233.11799.241", "org.jetbrains.plugins.go:233.11799.196", - // https://github.com/JetBrains/gradle-intellij-plugin/issues/1056 - "org.intellij.intelliLang" ) ), rider = RiderProfile( sdkVersion = "2023.3", - plugins = commonPlugins + listOf( - "rider-plugins-appender" // Workaround for https://youtrack.jetbrains.com/issue/IDEA-179607 - ), + bundledPlugins = commonPlugins, netFrameworkTarget = "net472", rdGenVersion = "2023.3.2", nugetVersion = "2023.3.0" @@ -103,17 +97,17 @@ object IdeVersions { gateway = ProductProfile( sdkFlavor = IdeFlavor.GW, sdkVersion = "241.14494-EAP-CANDIDATE-SNAPSHOT", - plugins = arrayOf("org.jetbrains.plugins.terminal") + bundledPlugins = listOf("org.jetbrains.plugins.terminal") ), community = ProductProfile( sdkFlavor = IdeFlavor.IC, sdkVersion = "2024.1", - plugins = commonPlugins + listOf( - "java", + bundledPlugins = commonPlugins + listOf( + "com.intellij.java", "com.intellij.gradle", "org.jetbrains.idea.maven", - // transitive for python - "org.toml.lang:241.14494.150", + ), + marketplacePlugins = listOf( "PythonCore:241.14494.240", "Docker:241.14494.251" ) @@ -121,27 +115,20 @@ object IdeVersions { ultimate = ProductProfile( sdkFlavor = IdeFlavor.IU, sdkVersion = "2024.1", - plugins = commonPlugins + listOf( + bundledPlugins = commonPlugins + listOf( "JavaScript", - // Transitive dependency needed for javascript - // Can remove when https://github.com/JetBrains/gradle-intellij-plugin/issues/608 is fixed - "com.intellij.css", "JavaScriptDebugger", "com.intellij.database", "com.jetbrains.codeWithMe", - // transitive for python - "org.toml.lang:241.14494.150", + ), + marketplacePlugins = listOf( "Pythonid:241.14494.314", "org.jetbrains.plugins.go:241.14494.240", - // https://github.com/JetBrains/gradle-intellij-plugin/issues/1056 - "org.intellij.intelliLang" ) ), rider = RiderProfile( sdkVersion = "2024.1", - plugins = commonPlugins + listOf( - "rider-plugins-appender" // Workaround for https://youtrack.jetbrains.com/issue/IDEA-179607 - ), + bundledPlugins = commonPlugins, netFrameworkTarget = "net472", rdGenVersion = "2024.1.1", nugetVersion = "2024.1.0" @@ -162,28 +149,18 @@ object IdeVersions { open class ProductProfile( val sdkFlavor: IdeFlavor, val sdkVersion: String, - val plugins: Array = emptyArray() -) { - fun version(): String? = if (!isLocalPath(sdkVersion)) { - sdkFlavor.name + "-" + sdkVersion - } else { - null - } - - fun localPath(): String? = sdkVersion.takeIf { - isLocalPath(it) - } - - private fun isLocalPath(str: String) = str.startsWith("/") || str.getOrNull(1) == ':' -} + val bundledPlugins: List = emptyList(), + val marketplacePlugins: List = emptyList() +) class RiderProfile( sdkVersion: String, - plugins: Array, val netFrameworkTarget: String, val rdGenVersion: String, // https://central.sonatype.com/artifact/com.jetbrains.rd/rd-gen/2023.2.3/versions - val nugetVersion: String // https://www.nuget.org/packages/JetBrains.Rider.SDK/ -) : ProductProfile(IdeFlavor.RD, sdkVersion, plugins) + val nugetVersion: String, // https://www.nuget.org/packages/JetBrains.Rider.SDK/ + bundledPlugins: List = emptyList(), + marketplacePlugins: List = emptyList(), +) : ProductProfile(IdeFlavor.RD, sdkVersion, bundledPlugins, marketplacePlugins) class Profile( val name: String, diff --git a/buildSrc/src/main/kotlin/software/aws/toolkits/gradle/intellij/ToolkitIntelliJExtension.kt b/buildSrc/src/main/kotlin/software/aws/toolkits/gradle/intellij/ToolkitIntelliJExtension.kt index fd9a5ee27ef..9cb147dcc0e 100644 --- a/buildSrc/src/main/kotlin/software/aws/toolkits/gradle/intellij/ToolkitIntelliJExtension.kt +++ b/buildSrc/src/main/kotlin/software/aws/toolkits/gradle/intellij/ToolkitIntelliJExtension.kt @@ -15,12 +15,8 @@ abstract class ToolkitIntelliJExtension(private val providers: ProviderFactory) fun ideProfile() = IdeVersions.ideProfile(providers) - fun version(): Provider = productProfile().flatMap { profile -> - providers.provider { profile.version() } - } - - fun localPath(): Provider = productProfile().flatMap { profile -> - providers.provider { profile.localPath() } + fun version(): Provider = productProfile().flatMap { profile -> + providers.provider { profile.sdkVersion } } fun productProfile(): Provider = ideFlavor.flatMap { flavor -> diff --git a/buildSrc/src/main/kotlin/temp-toolkit-intellij-root-conventions.gradle.kts b/buildSrc/src/main/kotlin/temp-toolkit-intellij-root-conventions.gradle.kts index b681fc6ab45..196bb3bdabc 100644 --- a/buildSrc/src/main/kotlin/temp-toolkit-intellij-root-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/temp-toolkit-intellij-root-conventions.gradle.kts @@ -1,32 +1,29 @@ // Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.create import org.gradle.kotlin.dsl.dependencies -import org.gradle.kotlin.dsl.getByType import org.gradle.kotlin.dsl.invoke import org.gradle.kotlin.dsl.project import org.gradle.kotlin.dsl.provideDelegate -import org.gradle.kotlin.dsl.withType -import org.gradle.testing.jacoco.plugins.JacocoPluginExtension -import org.gradle.testing.jacoco.plugins.JacocoTaskExtension -import org.jetbrains.intellij.tasks.DownloadRobotServerPluginTask -import org.jetbrains.intellij.tasks.RunIdeForUiTestTask -import org.jetbrains.intellij.utils.OpenedPackages +import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType +import org.jetbrains.intellij.platform.gradle.extensions.IntelliJPlatformExtension +import org.jetbrains.intellij.platform.gradle.plugins.project.DownloadRobotServerPluginTask +import org.jetbrains.intellij.platform.gradle.tasks.TestIdeUiTask import software.aws.toolkits.gradle.ciOnly import software.aws.toolkits.gradle.intellij.IdeFlavor import software.aws.toolkits.gradle.intellij.IdeVersions import software.aws.toolkits.gradle.intellij.ToolkitIntelliJExtension +import software.aws.toolkits.gradle.intellij.toolkitIntelliJ plugins { - id("org.jetbrains.intellij") id("toolkit-testing") // Needed so the coverage configurations are present id("toolkit-detekt") id("toolkit-publishing-conventions") + id("toolkit-publish-root-conventions") } -val toolkitIntelliJ = project.extensions.create("intellijToolkit").apply { +toolkitIntelliJ.apply { val runIdeVariant = providers.gradleProperty("runIdeVariant") ideFlavor.set(IdeFlavor.values().firstOrNull { it.name == runIdeVariant.orNull } ?: IdeFlavor.IC) } @@ -48,17 +45,14 @@ val gatewayResources = configurations.create("gatewayResources") { isCanBeConsumed = false } -intellij { - pluginName.set("aws-toolkit-jetbrains") - - localPath.set(toolkitIntelliJ.localPath()) - version.set(toolkitIntelliJ.version()) - - updateSinceUntilBuild.set(false) - instrumentCode.set(false) +intellijPlatform { + projectName = "aws-toolkit-jetbrains" + instrumentCode = false } tasks.prepareSandbox { + val pluginName = intellijPlatform.projectName + intoChild(pluginName.map { "$it/dotnet" }) .from(resharperDlls) @@ -72,6 +66,13 @@ tasks.test { } dependencies { + intellijPlatform { + val type = toolkitIntelliJ.ideFlavor.map { IntelliJPlatformType.fromCode(it.toString()) } + val version = toolkitIntelliJ.version() + + create(type, version) + } + implementation(project(":plugin-toolkit:jetbrains-core")) implementation(project(":plugin-toolkit:jetbrains-ultimate")) project.findProject(":plugin-toolkit:jetbrains-gateway")?.let { @@ -86,13 +87,10 @@ dependencies { // Enable coverage for the UI test target IDE ciOnly { - extensions.getByType().applyTo(tasks.withType()) -} -tasks.withType { - // TODO: https://github.com/gradle/gradle/issues/15383 - version.set(versionCatalogs.named("libs").findVersion("intellijRemoteRobot").get().requiredVersion) + extensions.getByType().applyTo(tasks.withType()) } -tasks.withType().all { + +tasks.withType().all { systemProperty("robot-server.port", remoteRobotPort) // mac magic systemProperty("ide.mac.message.dialogs.as.sheets", "false") @@ -118,13 +116,6 @@ tasks.withType().all { suspend.set(false) } - jvmArgs( - OpenedPackages + listOf( - // very noisy in UI tests - "--add-opens=java.desktop/javax.swing.text=ALL-UNNAMED", - ) - ) - ciOnly { configure { // sync with testing-subplugin diff --git a/buildSrc/src/main/kotlin/toolkit-integration-testing.gradle.kts b/buildSrc/src/main/kotlin/toolkit-integration-testing.gradle.kts index 1b18c62d891..ffc030fb2f8 100644 --- a/buildSrc/src/main/kotlin/toolkit-integration-testing.gradle.kts +++ b/buildSrc/src/main/kotlin/toolkit-integration-testing.gradle.kts @@ -1,10 +1,11 @@ +// Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +import org.jetbrains.intellij.platform.gradle.Constants.Configurations.Attributes import software.aws.toolkits.gradle.ciOnly import software.aws.toolkits.gradle.findFolders import software.aws.toolkits.gradle.intellij.IdeVersions -// Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - plugins { id("java") id("idea") @@ -31,10 +32,18 @@ sourceSets { configurations.getByName("integrationTestCompileClasspath") { extendsFrom(configurations.getByName(JavaPlugin.TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME)) + attributes { + attribute(Attributes.extracted, true) + attribute(Attributes.collected, true) + } } configurations.getByName("integrationTestRuntimeClasspath") { extendsFrom(configurations.getByName(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME)) + attributes { + attribute(Attributes.extracted, true) + attribute(Attributes.collected, true) + } isCanBeResolved = true } @@ -71,12 +80,6 @@ tasks.check { afterEvaluate { plugins.withType { - // weird implicit dependency issue, maybe with how the task graph works? - // or because tests are on the ide classpath for some reason? - tasks.named("classpathIndexCleanup") { - mustRunAfter(tasks.named("compileIntegrationTestKotlin")) - } - // intellij plugin overrides with instrumented classes that we don't want or need integTestTask.configure { testClassesDirs = integrationTests.output.classesDirs diff --git a/buildSrc/src/main/kotlin/toolkit-intellij-plugin.gradle.kts b/buildSrc/src/main/kotlin/toolkit-intellij-plugin.gradle.kts index ea9dd0a2119..b81305889cf 100644 --- a/buildSrc/src/main/kotlin/toolkit-intellij-plugin.gradle.kts +++ b/buildSrc/src/main/kotlin/toolkit-intellij-plugin.gradle.kts @@ -1,5 +1,47 @@ // Copyright 2024 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.aware.RunnableIdeAware +import software.aws.toolkits.gradle.ciOnly import software.aws.toolkits.gradle.intellij.ToolkitIntelliJExtension -project.extensions.create("intellijToolkit") +private val toolkitIntelliJ = project.extensions.create("intellijToolkit") + +plugins { + id("org.jetbrains.intellij.platform") +} + +intellijPlatform { + instrumentCode = false +} + +// there is an issue if this is declared more than once in a project (either directly or through script plugins) +repositories { + intellijPlatform { + defaultRepositories() + jetbrainsRuntime() + } +} + +dependencies { + intellijPlatform { + instrumentationTools() + } +} + +tasks.verifyPlugin { + isEnabled = false +} + +// CI keeps running out of RAM, so limit IDE instance count to 4 +ciOnly { + abstract class NoopBuildService : BuildService {} + val noopService = gradle.sharedServices.registerIfAbsent("noopService", NoopBuildService::class.java) { + maxParallelUsages = 4 + } + + tasks.matching { it is RunnableIdeAware }.all { + usesService(noopService) + } +} diff --git a/buildSrc/src/main/kotlin/toolkit-intellij-subplugin.gradle.kts b/buildSrc/src/main/kotlin/toolkit-intellij-subplugin.gradle.kts index 3c44813a4cc..517e0316b7c 100644 --- a/buildSrc/src/main/kotlin/toolkit-intellij-subplugin.gradle.kts +++ b/buildSrc/src/main/kotlin/toolkit-intellij-subplugin.gradle.kts @@ -3,10 +3,8 @@ import org.gradle.internal.os.OperatingSystem import org.gradle.testing.jacoco.plugins.JacocoTaskExtension.Output -import org.jetbrains.intellij.tasks.DownloadRobotServerPluginTask -import org.jetbrains.intellij.tasks.PatchPluginXmlTask -import org.jetbrains.intellij.tasks.RunIdeForUiTestTask -import org.jetbrains.intellij.utils.OpenedPackages +import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType +import org.jetbrains.intellij.platform.gradle.tasks.PatchPluginXmlTask import software.aws.toolkits.gradle.buildMetadata import software.aws.toolkits.gradle.ciOnly import software.aws.toolkits.gradle.findFolders @@ -22,8 +20,6 @@ plugins { id("toolkit-intellij-plugin") id("toolkit-kotlin-conventions") id("toolkit-testing") - id("org.jetbrains.intellij") - id("toolkit-patch-plugin-xml-conventions") } // TODO: https://github.com/gradle/gradle/issues/15383 @@ -82,18 +78,33 @@ tasks.processTestResources { } // Run after the project has been evaluated so that the extension (intellijToolkit) has been configured -intellij { +intellijPlatform { // find the name of first subproject depth, or root if not applied to a subproject hierarchy - val projectName = generateSequence(project) { it.parent }.first { it.depth <= 1 }.name - pluginName.convention(projectName) + projectName.convention(generateSequence(project) { it.parent }.first { it.depth <= 1 }.name) + instrumentCode = true +} + +dependencies { + intellijPlatform { + instrumentationTools() + + // annoying resolution issue that we dont wan't to bother fixing + if (!project.name.contains("jetbrains-gateway")) { + val type = toolkitIntelliJ.ideFlavor.map { IntelliJPlatformType.fromCode(it.toString()) } + val version = toolkitIntelliJ.version() - localPath.set(toolkitIntelliJ.localPath()) - version.set(toolkitIntelliJ.version()) + create(type, version) + } - plugins.set(toolkitIntelliJ.productProfile().map { it.plugins.toMutableList() }) + jetbrainsRuntime() + bundledPlugins(toolkitIntelliJ.productProfile().map { it.bundledPlugins }) + plugins(toolkitIntelliJ.productProfile().map { it.marketplacePlugins }) + } - downloadSources.set(toolkitIntelliJ.ideFlavor.map { it == IdeFlavor.IC && !project.isCi() }) - instrumentCode.set(toolkitIntelliJ.ideFlavor.map { it == IdeFlavor.IC || it == IdeFlavor.IU }) + // FIX_WHEN_MIN_IS_233: something weird with dependency transform in 232-only (pulling in 13.0?) but doesn't worth investigating at the moment + if (providers.gradleProperty("ideProfileName").getOrNull() == "2023.2") { + compileOnly("org.jetbrains:annotations:24.0.0") + } } tasks.jar { @@ -106,24 +117,12 @@ tasks.buildSearchableOptions { enabled = false } -// https://github.com/JetBrains/gradle-intellij-plugin/blob/829786d5d196ab942d7e6eb3e472ac0af776d3fa/src/main/kotlin/org/jetbrains/intellij/tasks/RunIdeBase.kt#L315 -val openedPackages = OpenedPackages + with(OperatingSystem.current()) { - when { - isWindows -> listOf( - "--add-opens=java.base/sun.nio.fs=ALL-UNNAMED", - ) - else -> emptyList() - } -} - tasks.withType().all { - systemProperty("log.dir", intellij.sandboxDir.map { "$it-test/logs" }.get()) + 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) - - jvmArgs(openedPackages) } tasks.withType { @@ -159,46 +158,4 @@ tasks.runIde { systemProperty("ide.plugins.snapshot.on.unload.fail", true) systemProperty("memory.snapshots.path", project.rootDir) systemProperty("idea.auto.reload.plugins", false) - - val alternativeIde = providers.environmentVariable("ALTERNATIVE_IDE") - if (alternativeIde.isPresent) { - // remove the trailing slash if there is one or else it will not work - val value = alternativeIde.get() - val path = File(value.trimEnd('/')) - if (path.exists()) { - ideDir.set(path) - } else { - throw GradleException("ALTERNATIVE_IDE path not found $value") - } - } -} - -// rewrite `runtimeElements` to use the `instrumentedJar` variant -// there should never be a reason to use the default artifact at runtime, but `testFixturesRuntimeElements` pulls in `runtimeElements` -// which is causing conflict between the `runtimeElements` and `instrumentedJar` variants -// additionally more cleanly solves another headache from the IDE defaulting to instrumented classes while navigating between modules -configurations.runtimeElements { - // remove the default artifact and replace with the instrumented jar - outgoing.artifacts.clear() - outgoing.artifacts(configurations.instrumentedJar.map { it.artifacts }) - - // replace default classes with instrumented classes - outgoing.variants { - get("classes").apply { - artifacts.clear() - artifact(tasks.instrumentCode) { - type = ArtifactTypeDefinition.JVM_CLASS_DIRECTORY - } - } - } -} - -// 1.x declares dependsOn, but we want mustRunAfter -// https://github.com/JetBrains/intellij-platform-gradle-plugin/blob/47e2de88e86ffdefd3f6f45c2bb3181366ee4fa4/src/main/kotlin/org/jetbrains/intellij/IntelliJPlugin.kt#L1702 -tasks.classpathIndexCleanup { - dependsOn.clear() - - project.tasks - .runCatching { named("compileTestKotlin") } - .onSuccess { mustRunAfter(it) } } diff --git a/buildSrc/src/main/kotlin/toolkit-kotlin-conventions.gradle.kts b/buildSrc/src/main/kotlin/toolkit-kotlin-conventions.gradle.kts index 4f4c6af3bce..5497874da62 100644 --- a/buildSrc/src/main/kotlin/toolkit-kotlin-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/toolkit-kotlin-conventions.gradle.kts @@ -21,7 +21,10 @@ dependencies { implementation(versionCatalog.findLibrary("kotlin-coroutines").get()) testFixturesApi(versionCatalog.findLibrary("kotlin-test").get()) - testFixturesApi(versionCatalog.findLibrary("kotlin-coroutinesDebug").get()) + testFixturesApi(versionCatalog.findLibrary("kotlin-coroutinesDebug").get()) { + // IDE provides JNA and results in conflicts + exclude(group = "net.java.dev.jna", module = "jna") + } testFixturesApi(versionCatalog.findLibrary("kotlin-coroutinesTest").get()) testFixturesApi(versionCatalog.findLibrary("mockk").get()) } diff --git a/buildSrc/src/main/kotlin/toolkit-patch-plugin-xml-conventions.gradle.kts b/buildSrc/src/main/kotlin/toolkit-patch-plugin-xml-conventions.gradle.kts deleted file mode 100644 index af7cf6ca8d3..00000000000 --- a/buildSrc/src/main/kotlin/toolkit-patch-plugin-xml-conventions.gradle.kts +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -import org.jetbrains.intellij.tasks.BuildPluginTask -import org.jetbrains.intellij.tasks.PatchPluginXmlTask -import software.aws.toolkits.gradle.buildMetadata -import software.aws.toolkits.gradle.intellij.IdeVersions -import software.aws.toolkits.gradle.intellij.ToolkitIntelliJExtension -import software.aws.toolkits.gradle.intellij.toolkitIntelliJ -import software.aws.toolkits.gradle.isCi - -plugins { - id("toolkit-intellij-plugin") -} - -val ideProfile = IdeVersions.ideProfile(project) -val toolkitVersion: String by project - -// please check changelog generation logic if this format is changed -version = "$toolkitVersion-${ideProfile.shortName}" - -tasks.withType().all { - sinceBuild.set(toolkitIntelliJ.ideProfile().map { it.sinceVersion }) - untilBuild.set(toolkitIntelliJ.ideProfile().map { it.untilVersion }) -} - -// attach the current commit hash on local builds -if (!project.isCi()) { - val buildMetadata = buildMetadata() - tasks.withType().all { - version.set("${project.version}+$buildMetadata") - } - - tasks.named("buildPlugin") { - archiveClassifier.set(buildMetadata) - } -} diff --git a/buildSrc/src/main/kotlin/toolkit-publish-root-conventions.gradle.kts b/buildSrc/src/main/kotlin/toolkit-publish-root-conventions.gradle.kts new file mode 100644 index 00000000000..16dacf82497 --- /dev/null +++ b/buildSrc/src/main/kotlin/toolkit-publish-root-conventions.gradle.kts @@ -0,0 +1,98 @@ +// Copyright 2024 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.tasks.BuildPluginTask +import org.jetbrains.intellij.platform.gradle.tasks.PatchPluginXmlTask +import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask +import software.aws.toolkits.gradle.buildMetadata +import software.aws.toolkits.gradle.intellij.IdeFlavor +import software.aws.toolkits.gradle.intellij.IdeVersions +import software.aws.toolkits.gradle.intellij.toolkitIntelliJ +import software.aws.toolkits.gradle.isCi + +// publish-root should imply publishing-conventions, but we keep separate so that gateway always has the GW flavor +plugins { + id("toolkit-intellij-plugin") +} + +val ideProfile = IdeVersions.ideProfile(project) +val toolkitVersion: String by project + +// please check changelog generation logic if this format is changed +version = "$toolkitVersion-${ideProfile.shortName}" + +tasks.withType().all { + sinceBuild.set(toolkitIntelliJ.ideProfile().map { it.sinceVersion }) + untilBuild.set(toolkitIntelliJ.ideProfile().map { it.untilVersion }) +} + +// attach the current commit hash on local builds +if (!project.isCi()) { + val buildMetadata = buildMetadata() + tasks.withType().all { + pluginVersion.set("${project.version}+$buildMetadata") + } + + tasks.named("buildPlugin") { + archiveClassifier.set(buildMetadata) + } +} + +intellijPlatform { + instrumentCode = false + + verifyPlugin { + ides { + // recommended() appears to resolve latest EAP for a product? + ide(provider { IntelliJPlatformType.IntellijIdeaCommunity }, toolkitIntelliJ.version()) + ide(provider { IntelliJPlatformType.IntellijIdeaUltimate }, toolkitIntelliJ.version()) + } + } +} + +dependencies { + intellijPlatform { + pluginVerifier() + + val alternativeIde = providers.environmentVariable("ALTERNATIVE_IDE") + if (alternativeIde.isPresent) { + // remove the trailing slash if there is one or else it will not work + val value = alternativeIde.get() + val path = File(value.trimEnd('/')) + if (path.exists()) { + local(path) + } else { + throw GradleException("ALTERNATIVE_IDE path not found $value") + } + } else { + val runIdeVariant = providers.gradleProperty("runIdeVariant") + + // prefer versions declared in IdeVersions + toolkitIntelliJ.apply { + ideFlavor.convention(IdeFlavor.values().firstOrNull { it.name == runIdeVariant.orNull } ?: IdeFlavor.IC) + } + val (type, version) = if (runIdeVariant.isPresent) { + val type = toolkitIntelliJ.ideFlavor.map { IntelliJPlatformType.fromCode(it.toString()) } + val version = toolkitIntelliJ.version() + + type to version + } else { + provider { IntelliJPlatformType.IntellijIdeaCommunity } to toolkitIntelliJ.version() + } + + create(type, version) + jetbrainsRuntime() + } + } +} + +// hack around: https://github.com/JetBrains/intellij-platform-gradle-plugin/issues/1620 +val pluginZip by configurations.creating { + isCanBeConsumed = true + isCanBeResolved = false +} + +artifacts { + add("pluginZip", tasks.buildPlugin) +} diff --git a/buildSrc/src/main/kotlin/toolkit-publishing-conventions.gradle.kts b/buildSrc/src/main/kotlin/toolkit-publishing-conventions.gradle.kts index e9c97acefe4..4ff8a69bce3 100644 --- a/buildSrc/src/main/kotlin/toolkit-publishing-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/toolkit-publishing-conventions.gradle.kts @@ -1,22 +1,27 @@ // Copyright 2024 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.tasks.VerifyPluginTask import software.aws.toolkits.gradle.intellij.IdeVersions plugins { - id("org.jetbrains.intellij") + id("org.jetbrains.intellij.platform") } -val ideProfile = IdeVersions.ideProfile(project) +intellijPlatform { + publishing { + val publishToken: String by project + val publishChannel: String by project -val publishToken: String by project -val publishChannel: String by project - -intellij { - version.set(ideProfile.community.version()) - localPath.set(ideProfile.community.localPath()) + token.set(publishToken) + channels.set(publishChannel.split(",").map { it.trim() }) + } - updateSinceUntilBuild.set(false) - instrumentCode.set(false) + verifyPlugin { + subsystemsToCheck.set(VerifyPluginTask.Subsystems.WITHOUT_ANDROID) + // need to tune this + failureLevel.set(listOf(VerifyPluginTask.FailureLevel.INVALID_PLUGIN)) + } } configurations { @@ -33,11 +38,9 @@ configurations { } } -tasks.check { - dependsOn(tasks.verifyPlugin) -} - -tasks.publishPlugin { - token.set(publishToken) - channels.set(publishChannel.split(",").map { it.trim() }) +// not run as part of check because of memory pressue issues +tasks.verifyPlugin { + isEnabled = true + // give each instance its own home dir + systemProperty("plugin.verifier.home.dir", temporaryDir) } diff --git a/buildspec/linuxTests.yml b/buildspec/linuxTests.yml index 91487a48596..82969e9e262 100644 --- a/buildspec/linuxTests.yml +++ b/buildspec/linuxTests.yml @@ -32,8 +32,12 @@ phases: fi - chmod +x gradlew - - su codebuild-user -c "./gradlew -PideProfileName=$ALTERNATIVE_IDE_PROFILE_NAME check coverageReport --info --console plain --continue" - - ./gradlew -PideProfileName=$ALTERNATIVE_IDE_PROFILE_NAME :plugin-toolkit:intellij-standalone:buildPlugin :plugin-core:buildPlugin :plugin-amazonq:buildPlugin + - su codebuild-user -c "./gradlew -PideProfileName=$ALTERNATIVE_IDE_PROFILE_NAME check coverageReport --info --console plain --continue -scan" + - ./gradlew -PideProfileName=$ALTERNATIVE_IDE_PROFILE_NAME :plugin-toolkit:intellij-standalone:buildPlugin :plugin-core:buildPlugin :plugin-amazonq:buildPlugin :plugin-toolkit:intellij-standalone:verifyPlugin :plugin-core:verifyPlugin :plugin-amazonq:verifyPlugin + - | + if ./gradlew -PideProfileName=$ALTERNATIVE_IDE_PROFILE_NAME projects --console plain | grep -q "Project ':plugin-toolkit:jetbrains-gateway'"; then + ./gradlew -PideProfileName=$ALTERNATIVE_IDE_PROFILE_NAME :plugin-toolkit:jetbrains-gateway:buildPlugin :plugin-toolkit:jetbrains-gateway:verifyPlugin + fi - VCS_COMMIT_ID="${CODEBUILD_RESOLVED_SOURCE_VERSION}" - CI_BUILD_URL=$(echo $CODEBUILD_BUILD_URL | sed 's/#/%23/g') # Encode `#` in the URL because otherwise the url is clipped in the Codecov.io site - CI_BUILD_ID="${CODEBUILD_BUILD_ID}" diff --git a/buildspec/windowsTests.yml b/buildspec/windowsTests.yml index c4773bd168d..30a27348451 100644 --- a/buildspec/windowsTests.yml +++ b/buildspec/windowsTests.yml @@ -36,8 +36,8 @@ phases: $Env:CODEARTIFACT_AUTH_TOKEN=aws codeartifact get-authorization-token --domain $Env:CODEARTIFACT_DOMAIN_NAME --query authorizationToken --output text --duration-seconds 3600 } - # Rider is very expensive (spikes our CI jobs to 50% CPU, so let it do the prep work in parallel, but run tests later - ./gradlew -PideProfileName="$Env:ALTERNATIVE_IDE_PROFILE_NAME" check :plugin-toolkit:jetbrains-rider:compileTestKotlin --info --console plain --continue + # Rider is very expensive (spikes our CI jobs to 50% CPU, so let it do the prep work in parallel, but run tests later + ./gradlew -PideProfileName="$Env:ALTERNATIVE_IDE_PROFILE_NAME" check :plugin-toolkit:jetbrains-rider:compileTestKotlin --info --console plain --continue --scan --stacktrace if ($LastExitCode -ne 0) { Write-Host "Command failed with exit code $LastExitCode" exit -1 diff --git a/gradle.properties b/gradle.properties index bc5f2d7d7a1..23f4abccb9e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ toolkitVersion=3.14-SNAPSHOT publishToken= publishChannel= -ideProfileName=2023.3 +ideProfileName=2024.1 remoteRobotPort=8080 @@ -25,3 +25,9 @@ systemProp.gradle.enterprise.testretry.enabled=false # outputs to build/reports/kotlin-build kotlin.build.report.output=file + +# don't bundle Kotlin stdlib with plugin +kotlin.stdlib.default.dependency=false + +# need the maven variant to build rider correctly +org.jetbrains.intellij.platform.buildFeature.useBinaryReleases=false diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 342aa0bbc71..975664ccc31 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,7 +6,8 @@ assertJ = "3.26.0" awsSdk = "2.25.33" commonmark = "0.17.1" detekt = "1.23.6" -intellijGradle = "1.17.3" +intellijExt = "1.1.8" +intellijGradle = "2.0.0-beta7" intellijRemoteRobot = "0.11.22" jackson = "2.16.1" jacoco = "0.8.12" @@ -70,7 +71,8 @@ detekt-api = { module = "io.gitlab.arturbosch.detekt:detekt-api", version.ref = detekt-formattingRules = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" } detekt-test = { module = "io.gitlab.arturbosch.detekt:detekt-test", version.ref = "detekt" } gradlePlugin-detekt = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt" } -gradlePlugin-intellij = { module = "org.jetbrains.intellij:org.jetbrains.intellij.gradle.plugin", version.ref = "intellijGradle" } +gradlePlugin-ideaExt = { module = "gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext", version.ref = "intellijExt" } +gradlePlugin-intellij = { module = "org.jetbrains.intellij.platform:intellij-platform-gradle-plugin", version.ref = "intellijGradle" } gradlePlugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } gradlePlugin-testLogger = { module = "com.adarshr:gradle-test-logger-plugin", version.ref = "testLogger" } gradlePlugin-testRetry = { module = "org.gradle:test-retry-gradle-plugin", version.ref = "testRetry" } diff --git a/plugins/amazonq/build.gradle.kts b/plugins/amazonq/build.gradle.kts index b7afaf82e2f..bda309b8991 100644 --- a/plugins/amazonq/build.gradle.kts +++ b/plugins/amazonq/build.gradle.kts @@ -1,19 +1,21 @@ // Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 +import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType import software.aws.toolkits.gradle.changelog.tasks.GeneratePluginChangeLog import software.aws.toolkits.gradle.intellij.IdeFlavor import software.aws.toolkits.gradle.intellij.IdeVersions +import software.aws.toolkits.gradle.intellij.toolkitIntelliJ plugins { id("toolkit-publishing-conventions") - id("toolkit-patch-plugin-xml-conventions") + id("toolkit-publish-root-conventions") id("toolkit-jvm-conventions") } val changelog = tasks.register("pluginChangeLog") { includeUnreleased.set(true) - changeLogFile.set(project.file("$buildDir/changelog/change-notes.xml")) + changeLogFile.value(layout.buildDirectory.file("changelog/change-notes.xml")) } tasks.jar { @@ -23,15 +25,11 @@ tasks.jar { } } -intellij { - plugins.set( - listOf( - project(":plugin-core") - ) - ) -} - dependencies { + intellijPlatform { + localPlugin(project(":plugin-core", "pluginZip")) + } + implementation(project(":plugin-amazonq:chat")) implementation(project(":plugin-amazonq:codetransform")) implementation(project(":plugin-amazonq:codewhisperer")) @@ -62,7 +60,5 @@ tasks.check { subDirs.forEach { insideService-> dependsOn(":plugin-amazonq:${serviceSubDir.name}:${insideService.name}:check") } - } - } diff --git a/plugins/amazonq/chat/jetbrains-community/build.gradle.kts b/plugins/amazonq/chat/jetbrains-community/build.gradle.kts index ee03943c631..45a5490a2c8 100644 --- a/plugins/amazonq/chat/jetbrains-community/build.gradle.kts +++ b/plugins/amazonq/chat/jetbrains-community/build.gradle.kts @@ -11,11 +11,11 @@ intellijToolkit { ideFlavor.set(IdeFlavor.IC) } -intellij { - plugins.add(project(":plugin-core")) -} - dependencies { + intellijPlatform { + localPlugin(project(":plugin-core", "pluginZip")) + } + implementation(project(":plugin-amazonq:shared:jetbrains-community")) // everything references codewhisperer, which is not ideal implementation(project(":plugin-amazonq:codewhisperer:jetbrains-community")) diff --git a/plugins/amazonq/codetransform/jetbrains-community/build.gradle.kts b/plugins/amazonq/codetransform/jetbrains-community/build.gradle.kts index af259791b04..e1d4800874a 100644 --- a/plugins/amazonq/codetransform/jetbrains-community/build.gradle.kts +++ b/plugins/amazonq/codetransform/jetbrains-community/build.gradle.kts @@ -11,11 +11,11 @@ intellijToolkit { ideFlavor.set(IdeFlavor.IC) } -intellij { - plugins.add(project(":plugin-core")) -} - dependencies { + intellijPlatform { + localPlugin(project(":plugin-core", "pluginZip")) + } + implementation(project(":plugin-amazonq:shared:jetbrains-community")) // hack because transform has a chat entrypoint implementation(project(":plugin-amazonq:chat:jetbrains-community")) @@ -28,10 +28,10 @@ dependencies { } // hack because our test structure currently doesn't make complete sense -tasks.prepareTestingSandbox { +tasks.prepareTestSandbox { val pluginXmlJar = project(":plugin-amazonq").tasks.jar dependsOn(pluginXmlJar) - intoChild(pluginName.map { "$it/lib" }) + intoChild(intellijPlatform.projectName.map { "$it/lib" }) .from(pluginXmlJar) } diff --git a/plugins/amazonq/codewhisperer/jetbrains-community/build.gradle.kts b/plugins/amazonq/codewhisperer/jetbrains-community/build.gradle.kts index 64d2482b6d0..0dc093f25cf 100644 --- a/plugins/amazonq/codewhisperer/jetbrains-community/build.gradle.kts +++ b/plugins/amazonq/codewhisperer/jetbrains-community/build.gradle.kts @@ -11,11 +11,11 @@ intellijToolkit { ideFlavor.set(IdeFlavor.IC) } -intellij { - plugins.add(project(":plugin-core")) -} - dependencies { + intellijPlatform { + localPlugin(project(":plugin-core", "pluginZip")) + } + compileOnly(project(":plugin-core:jetbrains-community")) implementation(project(":plugin-amazonq:shared:jetbrains-community")) @@ -27,10 +27,10 @@ dependencies { } // hack because our test structure currently doesn't make complete sense -tasks.prepareTestingSandbox { +tasks.prepareTestSandbox { val pluginXmlJar = project(":plugin-amazonq").tasks.jar dependsOn(pluginXmlJar) - intoChild(pluginName.map { "$it/lib" }) + intoChild(intellijPlatform.projectName.map { "$it/lib" }) .from(pluginXmlJar) } diff --git a/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/codescan/CodeWhispererCodeScanManager.kt b/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/codescan/CodeWhispererCodeScanManager.kt index 86bdee673e9..20d447185c3 100644 --- a/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/codescan/CodeWhispererCodeScanManager.kt +++ b/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/codescan/CodeWhispererCodeScanManager.kt @@ -75,7 +75,6 @@ import software.aws.toolkits.jetbrains.services.codewhisperer.util.runIfIdcConne import software.aws.toolkits.jetbrains.utils.isQConnected import software.aws.toolkits.jetbrains.utils.isQExpired import software.aws.toolkits.jetbrains.utils.isRunningOnRemoteBackend -import software.aws.toolkits.jetbrains.utils.offsetSuggestedFix import software.aws.toolkits.resources.message import software.aws.toolkits.telemetry.Result import java.time.Duration @@ -792,3 +791,18 @@ data class CodeWhispererCodeScanIssue( return TextRange.create(startOffset, endOffset) } } + +private fun offsetSuggestedFix(suggestedFix: SuggestedFix, lines: Int): SuggestedFix { + val updatedCode = suggestedFix.code.replace( + Regex("""(@@ -)(\d+)(,\d+ \+)(\d+)(,\d+ @@)""") + ) { result -> + val prefix = result.groupValues[1] + val startLine = result.groupValues[2].toInt() + lines + val middle = result.groupValues[3] + val endLine = result.groupValues[4].toInt() + lines + val suffix = result.groupValues[5] + "$prefix$startLine$middle$endLine$suffix" + } + + return suggestedFix.copy(code = updatedCode) +} diff --git a/plugins/amazonq/codewhisperer/jetbrains-ultimate/build.gradle.kts b/plugins/amazonq/codewhisperer/jetbrains-ultimate/build.gradle.kts index a4aa4970d79..a1578ab0c85 100644 --- a/plugins/amazonq/codewhisperer/jetbrains-ultimate/build.gradle.kts +++ b/plugins/amazonq/codewhisperer/jetbrains-ultimate/build.gradle.kts @@ -11,11 +11,11 @@ intellijToolkit { ideFlavor.set(IdeFlavor.IU) } -intellij { - plugins.add(project(":plugin-core")) -} - dependencies { + intellijPlatform { + localPlugin(project(":plugin-core", "pluginZip")) + } + compileOnly(project(":plugin-amazonq:codewhisperer:jetbrains-community")) compileOnly(project(":plugin-amazonq:shared:jetbrains-ultimate")) diff --git a/plugins/amazonq/shared/jetbrains-community/build.gradle.kts b/plugins/amazonq/shared/jetbrains-community/build.gradle.kts index 739b101506e..30cfdb7bb05 100644 --- a/plugins/amazonq/shared/jetbrains-community/build.gradle.kts +++ b/plugins/amazonq/shared/jetbrains-community/build.gradle.kts @@ -11,11 +11,11 @@ intellijToolkit { ideFlavor.set(IdeFlavor.IC) } -intellij { - plugins.add(project(":plugin-core")) -} - dependencies { + intellijPlatform { + localPlugin(project(":plugin-core", "pluginZip")) + } + compileOnlyApi(project(":plugin-core:jetbrains-community")) // CodeWhispererTelemetryService uses a CircularFifoQueue diff --git a/plugins/core/build.gradle.kts b/plugins/core/build.gradle.kts index b1988fcf387..c28bb4dadb2 100644 --- a/plugins/core/build.gradle.kts +++ b/plugins/core/build.gradle.kts @@ -6,7 +6,7 @@ import software.aws.toolkits.gradle.intellij.IdeVersions plugins { id("toolkit-publishing-conventions") - id("toolkit-patch-plugin-xml-conventions") + id("toolkit-publish-root-conventions") id("toolkit-jvm-conventions") } diff --git a/plugins/core/jetbrains-community/build.gradle.kts b/plugins/core/jetbrains-community/build.gradle.kts index 14f35a545f5..e177e9045d4 100644 --- a/plugins/core/jetbrains-community/build.gradle.kts +++ b/plugins/core/jetbrains-community/build.gradle.kts @@ -3,6 +3,7 @@ import io.gitlab.arturbosch.detekt.Detekt import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask +import org.jetbrains.intellij.platform.gradle.TestFrameworkType import software.aws.toolkits.gradle.intellij.IdeFlavor import software.aws.toolkits.telemetry.generator.gradle.GenerateTelemetry @@ -37,7 +38,26 @@ intellijToolkit { ideFlavor.set(IdeFlavor.IC) } +// expose intellij test framework to fixture consumers +configurations.testFixturesCompileOnlyApi { + extendsFrom( + configurations.intellijPlatformTestDependencies.get() + ) +} + +// intellij java-test-framework pollutes test classpath with extracted java plugins +configurations.testFixturesApi { + exclude("com.jetbrains.intellij.java", "java") + exclude("com.jetbrains.intellij.java", "java-impl") +} + dependencies { + intellijPlatform { + testFramework(TestFrameworkType.Platform) + testFramework(TestFrameworkType.JUnit5) + testFramework(TestFrameworkType.Plugin.Java) + } + compileOnlyApi(project(":plugin-core:core")) compileOnlyApi(libs.aws.apacheClient) compileOnlyApi(libs.aws.nettyClient) @@ -50,7 +70,7 @@ dependencies { exclude(group = "org.apache.httpcomponents.client5") } - testRuntimeOnly(project(":plugin-core:core")) + testImplementation(project(":plugin-core:core")) testRuntimeOnly(project(":plugin-core:resources")) testRuntimeOnly(project(":plugin-core:sdk-codegen")) } @@ -65,10 +85,10 @@ tasks.withType { } // hack because our test structure currently doesn't make complete sense -tasks.prepareTestingSandbox { +tasks.prepareTestSandbox { val pluginXmlJar = project(":plugin-core").tasks.jar dependsOn(pluginXmlJar) - intoChild(pluginName.map { "$it/lib" }) + intoChild(intellijPlatform.projectName.map { "$it/lib" }) .from(pluginXmlJar) } diff --git a/plugins/toolkit/intellij-standalone/build.gradle.kts b/plugins/toolkit/intellij-standalone/build.gradle.kts index 0e9d4f3d79a..560176ddf54 100644 --- a/plugins/toolkit/intellij-standalone/build.gradle.kts +++ b/plugins/toolkit/intellij-standalone/build.gradle.kts @@ -5,9 +5,14 @@ plugins { id("temp-toolkit-intellij-root-conventions") } -intellij { - pluginName.set("aws-toolkit-jetbrains-standalone") - plugins.add(project(":plugin-core")) +intellijPlatform { + projectName = "aws-toolkit-jetbrains-standalone" +} + +dependencies { + intellijPlatform { + localPlugin(project(":plugin-core", "pluginZip")) + } } tasks.check { diff --git a/plugins/toolkit/jetbrains-core/build.gradle.kts b/plugins/toolkit/jetbrains-core/build.gradle.kts index 44e4768ba8e..56f2dfa5a91 100644 --- a/plugins/toolkit/jetbrains-core/build.gradle.kts +++ b/plugins/toolkit/jetbrains-core/build.gradle.kts @@ -1,15 +1,19 @@ // Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import com.jetbrains.plugin.structure.base.utils.inputStream -import com.jetbrains.plugin.structure.base.utils.simpleName import com.jetbrains.plugin.structure.intellij.utils.JDOMUtil -import org.jetbrains.intellij.transformXml +import org.jdom2.Document +import org.jdom2.output.Format +import org.jdom2.output.XMLOutputter import software.aws.toolkits.gradle.buildMetadata import software.aws.toolkits.gradle.changelog.tasks.GeneratePluginChangeLog import software.aws.toolkits.gradle.intellij.IdeFlavor import software.aws.toolkits.gradle.intellij.IdeVersions import software.aws.toolkits.gradle.isCi +import java.io.StringWriter +import java.nio.file.Path +import kotlin.io.path.inputStream +import kotlin.io.path.writeText val toolkitVersion: String by project val ideProfile = IdeVersions.ideProfile(project) @@ -26,8 +30,10 @@ intellijToolkit { ideFlavor.set(IdeFlavor.IC) } -intellij { - plugins.add(project(":plugin-core")) +dependencies { + intellijPlatform { + localPlugin(project(":plugin-core", "pluginZip")) + } } val changelog = tasks.register("pluginChangeLog") { @@ -53,22 +59,23 @@ tasks.integrationTest { systemProperty("aws.dev.useDAG", true) } -val gatewayPluginXml = tasks.create("patchPluginXmlForGateway") { - pluginXmlFiles.set(tasks.patchPluginXml.map { it.pluginXmlFiles }.get()) - destinationDir.set(project.buildDir.resolve("patchedPluginXmlFilesGW")) - +val gatewayPluginXml = tasks.create("pluginXmlForGateway") { val buildSuffix = if (!project.isCi()) "+${buildMetadata()}" else "" - version.set("GW-$toolkitVersion-${ideProfile.shortName}$buildSuffix") + pluginVersion.set("GW-$toolkitVersion-${ideProfile.shortName}$buildSuffix") +} + +val patchGatewayPluginXml by tasks.creating { + dependsOn(gatewayPluginXml) + + val output = temporaryDir.resolve("plugin.xml") + outputs.file(output) // jetbrains expects gateway plugin to be dynamic doLast { - pluginXmlFiles.get() + gatewayPluginXml.outputFile.asFile .map(File::toPath) - .forEach { p -> - val path = destinationDir.get() - .asFile.toPath().toAbsolutePath() - .resolve(p.simpleName) - + .get() + .let { path -> val document = path.inputStream().use { inputStream -> JDOMUtil.loadDocument(inputStream) } @@ -77,7 +84,7 @@ val gatewayPluginXml = tasks.create("gatewayJar") { // unclear why the exclude() statement didn't work duplicatesStrategy = DuplicatesStrategy.WARN - dependsOn(tasks.instrumentedJar) + dependsOn(tasks.instrumentedJar, patchGatewayPluginXml) archiveBaseName.set("aws-toolkit-jetbrains-IC-GW") from(tasks.instrumentedJar.get().outputs.files.map { zipTree(it) }) { @@ -103,7 +110,7 @@ val gatewayJar = tasks.create("gatewayJar") { exclude("**/inactive") } - from(gatewayPluginXml) { + from(patchGatewayPluginXml) { into("META-INF") } @@ -127,6 +134,9 @@ tasks.prepareSandbox { tasks.testJar { // classpath.index is a duplicate duplicatesStrategy = DuplicatesStrategy.INCLUDE + + // not sure why this is getting pulled in + exclude("**/plugin.xml") } tasks.processTestResources { @@ -172,3 +182,17 @@ dependencies { testImplementation(libs.slf4j.api) testRuntimeOnly(libs.slf4j.jdk14) } + +fun transformXml(document: Document, path: Path) { + val xmlOutput = XMLOutputter() + xmlOutput.format.apply { + indent = " " + omitDeclaration = true + textMode = Format.TextMode.TRIM + } + + StringWriter().use { + xmlOutput.output(document, it) + path.writeText(text = it.toString()) + } +} diff --git a/plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/services/lambda/sam/SamCommonUtils.kt b/plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/services/lambda/sam/SamCommonUtils.kt index 3aec8c2f9d6..b27500be6dd 100644 --- a/plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/services/lambda/sam/SamCommonUtils.kt +++ b/plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/services/lambda/sam/SamCommonUtils.kt @@ -15,7 +15,6 @@ import com.intellij.openapi.project.guessProjectDir import com.intellij.openapi.roots.ModuleRootManager import com.intellij.openapi.ui.ValidationInfo import com.intellij.openapi.vfs.VirtualFile -import com.intellij.testFramework.runInEdtAndGet import kotlinx.coroutines.future.await import kotlinx.coroutines.runBlocking import org.jetbrains.yaml.YAMLFileType @@ -28,6 +27,7 @@ import software.aws.toolkits.jetbrains.services.cloudformation.Parameter import software.aws.toolkits.jetbrains.services.cloudformation.validateSamTemplateHasResources import software.aws.toolkits.jetbrains.ui.KeyValueTextField import software.aws.toolkits.jetbrains.ui.ResourceSelector +import software.aws.toolkits.jetbrains.utils.computeOnEdt import software.aws.toolkits.jetbrains.utils.notifyError import software.aws.toolkits.jetbrains.utils.ui.find import software.aws.toolkits.resources.message @@ -74,7 +74,7 @@ object SamTemplateFileUtils { fun retrieveSamTemplate(e: AnActionEvent, project: Project): VirtualFile? { if (e.place == ToolkitPlaces.EXPLORER_TOOL_WINDOW) { - return runInEdtAndGet { + return computeOnEdt { FileChooser.chooseFile( FileChooserDescriptorFactory.createSingleFileDescriptor(YAMLFileType.YML), project, diff --git a/plugins/toolkit/jetbrains-core/test-plugin-shim.xml b/plugins/toolkit/jetbrains-core/test-plugin-shim.xml deleted file mode 100644 index cb9a42454d4..00000000000 --- a/plugins/toolkit/jetbrains-core/test-plugin-shim.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - aws.toolkit.core - - diff --git a/plugins/toolkit/jetbrains-gateway/build.gradle.kts b/plugins/toolkit/jetbrains-gateway/build.gradle.kts index b8af4e92375..b1c19d835e9 100644 --- a/plugins/toolkit/jetbrains-gateway/build.gradle.kts +++ b/plugins/toolkit/jetbrains-gateway/build.gradle.kts @@ -2,8 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 import net.bytebuddy.utility.RandomString -import org.jetbrains.intellij.tasks.PrepareSandboxTask +import org.jetbrains.intellij.platform.gradle.TestFrameworkType +import org.jetbrains.intellij.platform.gradle.tasks.PrepareSandboxTask import software.aws.toolkits.gradle.intellij.IdeFlavor +import software.aws.toolkits.gradle.intellij.toolkitIntelliJ plugins { id("toolkit-kotlin-conventions") @@ -11,17 +13,17 @@ plugins { id("toolkit-testing") id("toolkit-intellij-subplugin") id("toolkit-integration-testing") -} - -intellij { - pluginName.set("aws-toolkit-jetbrains") - type.set("GW") + id("toolkit-publishing-conventions") } intellijToolkit { ideFlavor.set(IdeFlavor.GW) } +intellijPlatform { + projectName = "aws-toolkit-jetbrains" +} + sourceSets { create("gatewayOnly") { java { @@ -43,7 +45,29 @@ val gatewayOnlyResourcesJar by tasks.registering(Jar::class) { from(processGatewayOnlyResources) } +listOf( + "intellijPlatformDependency", + "intellijPluginVerifierIdesDependency", +).forEach { configurationName -> + configurations[configurationName].dependencies.addLater( + toolkitIntelliJ.version().map { + dependencies.create( + group = "com.jetbrains.gateway", + name = "JetBrainsGateway", + version = it, + ) + } + ) +} + dependencies { + intellijPlatform { + pluginVerifier() + + testFramework(TestFrameworkType.JUnit5) + testFramework(TestFrameworkType.Bundled) + } + // link against :j-c: and rely on :intellij:buildPlugin to pull in :j-c:instrumentedJar, but gateway variant when runIde/buildPlugin from :jetbrains-gateway compileOnly(project(":plugin-toolkit:jetbrains-core")) gatewayOnlyRuntimeOnly(project(":plugin-toolkit:jetbrains-core", "gatewayArtifacts")) @@ -59,8 +83,6 @@ dependencies { testRuntimeOnly(project(":plugin-toolkit:jetbrains-core", "gatewayArtifacts")) testImplementation(testFixtures(project(":plugin-core:jetbrains-community"))) testImplementation(project(path = ":plugin-toolkit:jetbrains-core", configuration = "testArtifacts")) - testImplementation(libs.kotlin.coroutinesTest) - testImplementation(libs.kotlin.coroutinesDebug) testImplementation(libs.wiremock) testImplementation(libs.bundles.sshd) } @@ -120,19 +142,19 @@ tasks.jar { } tasks.withType().all { - intoChild(pluginName.map { "$it/gateway-resources" }) + intoChild(intellijPlatform.projectName.map { "$it/gateway-resources" }) .from(gatewayResourcesDir) } listOf( tasks.prepareSandbox, - tasks.prepareTestingSandbox + tasks.prepareTestSandbox ).forEach { it.configure { - runtimeClasspathFiles.set(gatewayOnlyRuntimeClasspath) + runtimeClasspath.setFrom(gatewayOnlyRuntimeClasspath) dependsOn(gatewayOnlyResourcesJar) - intoChild(pluginName.map { "$it/lib" }) + intoChild(intellijPlatform.projectName.map { "$it/lib" }) .from(gatewayOnlyResourcesJar) } } @@ -147,32 +169,7 @@ tasks.buildPlugin { archiveClassifier.set(classifier) } -val publishToken: String by project -val publishChannel: String by project -tasks.publishPlugin { - token.set(publishToken) - channels.set(publishChannel.split(",").map { it.trim() }) -} - tasks.integrationTest { val testToken = RandomString.make(32) environment("CWM_HOST_STATUS_OVER_HTTP_TOKEN", testToken) } - -configurations { - all { - // IDE provides netty - exclude("io.netty") - } - - // Make sure we exclude stuff we either A) ships with IDE, B) we don't use to cut down on size - runtimeClasspath { - exclude(group = "org.slf4j") - exclude(group = "org.jetbrains.kotlin") - exclude(group = "org.jetbrains.kotlinx") - } -} - -tasks.check { - dependsOn(tasks.verifyPlugin) -} diff --git a/plugins/toolkit/jetbrains-gateway/tst/software/aws/toolkits/jetbrains/gateway/connection/SshCommandLineTest.kt b/plugins/toolkit/jetbrains-gateway/tst/software/aws/toolkits/jetbrains/gateway/connection/SshCommandLineTest.kt index d5bc11e5b70..0c4d093a85f 100644 --- a/plugins/toolkit/jetbrains-gateway/tst/software/aws/toolkits/jetbrains/gateway/connection/SshCommandLineTest.kt +++ b/plugins/toolkit/jetbrains-gateway/tst/software/aws/toolkits/jetbrains/gateway/connection/SshCommandLineTest.kt @@ -8,6 +8,9 @@ import com.github.tomakehurst.wiremock.client.WireMock.any import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.core.WireMockConfiguration import com.github.tomakehurst.wiremock.junit.WireMockClassRule +import com.intellij.execution.process.ProcessEvent +import com.intellij.execution.process.ProcessListener +import com.intellij.openapi.util.Key import com.intellij.testFramework.ApplicationRule import com.intellij.util.io.HttpRequests import com.intellij.util.net.NetUtils @@ -63,7 +66,29 @@ class SshCommandLineTest { SshCommandLine("localhost", port = sshServer.server.port) .knownHostsLocation(tempFolder.newFile().toPath()) .localPortForward(localPort, wireMockPort) - .executeInBackground() + .executeInBackground( + object : ProcessListener { + override fun startNotified(event: ProcessEvent) { + println("ssh client: startNotified") + } + + override fun processTerminated(event: ProcessEvent) { + println("ssh client: processTerminated, exit: ${event.exitCode}") + } + + override fun processWillTerminate(event: ProcessEvent, willBeDestroyed: Boolean) { + println("ssh client: processWillTerminate, willBeDestroyed: $willBeDestroyed") + } + + override fun onTextAvailable(event: ProcessEvent, outputType: Key<*>) { + println("ssh client: onTextAvailable: ${event.text}") + } + + override fun processNotStarted() { + println("ssh client: processNotStarted") + } + } + ) // race between ssh background process and client spinUntil(5_000) { sshServer.clientIsConnected() } diff --git a/plugins/toolkit/jetbrains-rider/build.gradle.kts b/plugins/toolkit/jetbrains-rider/build.gradle.kts index 4184d547054..d08d4f70242 100644 --- a/plugins/toolkit/jetbrains-rider/build.gradle.kts +++ b/plugins/toolkit/jetbrains-rider/build.gradle.kts @@ -6,7 +6,8 @@ import com.jetbrains.rd.generator.gradle.RdGenPlugin import com.jetbrains.rd.generator.gradle.RdGenTask import io.gitlab.arturbosch.detekt.Detekt import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask -import org.jetbrains.intellij.tasks.PrepareSandboxTask +import org.jetbrains.intellij.platform.gradle.TestFrameworkType +import org.jetbrains.intellij.platform.gradle.tasks.PrepareSandboxTask import software.aws.toolkits.gradle.intellij.IdeFlavor import software.aws.toolkits.gradle.intellij.IdeVersions import java.nio.file.Path @@ -40,11 +41,6 @@ intellijToolkit { ideFlavor.set(IdeFlavor.RD) } -intellij { - type.set("RD") - plugins.add(project(":plugin-core")) -} - sourceSets { main { java.srcDirs(layout.buildDirectory.dir("generated-src")) @@ -52,6 +48,12 @@ sourceSets { } dependencies { + intellijPlatform { + localPlugin(project(":plugin-core", "pluginZip")) + testFramework(TestFrameworkType.Bundled) + testFramework(TestFrameworkType.Plugin.ReSharper) + } + implementation(project(":plugin-toolkit:jetbrains-core")) testImplementation(project(":plugin-toolkit:jetbrains-core")) @@ -96,14 +98,21 @@ val rdgenDir = File("$nonLazyBuildDir/rdgen/") rdgenDir.mkdirs() +// https://github.com/JetBrains/resharper-unity/blob/master/rider/build.gradle.kts +val rdLibDirectory: () -> File = { file(intellijPlatform.platformPath.resolve("lib/rd/")) } + +val rdModelJarFile: File by lazy { + val jarFile = File(rdLibDirectory(), "rider-model.jar").canonicalFile + assert(jarFile.isFile) + return@lazy jarFile +} + configure { verbose = true hashFolder = rdgenDir.toString() classpath({ - val ijDependency = tasks.setupDependencies.flatMap { it.idea }.map { it.classes }.get() - println("Calculating classpath for rdgen, intellij.ideaDependency is: $ijDependency") - File(ijDependency, "lib/rd").resolve("rider-model.jar").absolutePath + rdModelJarFile }) sources(projectDir.resolve("protocol/model")) @@ -171,8 +180,6 @@ val prepareBuildProps = tasks.register("prepareBuildProps") { val prepareNuGetConfig = tasks.register("prepareNuGetConfig") { group = backendGroup - dependsOn(tasks.setupDependencies) - val nugetConfigPath = File(projectDir, "NuGet.Config") // FIX_WHEN_MIN_IS_211 remove the projectDir one above val nugetConfigPath211 = Path.of(projectDir.absolutePath, "testData", "NuGet.config").toFile() @@ -233,10 +240,10 @@ val buildReSharperPlugin = tasks.register("buildReSharperPlugin") { } fun getNugetPackagesPath(): File { - val sdkPath = tasks.setupDependencies.flatMap { it.idea }.map { it.classes }.get() + val sdkPath = intellijPlatform.platformPath println("SDK path: $sdkPath") - val riderSdk = File(sdkPath, "lib/DotNetSdkForRdPlugins") + val riderSdk = sdkPath.resolve("lib").resolve("DotNetSdkForRdPlugins").toAbsolutePath().toFile() println("NuGet packages: $riderSdk") if (!riderSdk.isDirectory) error("$riderSdk does not exist or not a directory") @@ -287,15 +294,15 @@ tasks.clean { // `runIde` depends on `prepareSandbox` task and then executes IJ inside the sandbox dir // `prepareSandbox` depends on the standard Java `jar` and then copies everything into the sandbox dir -intellij { +intellijPlatform { // kotlin and .NET parts of the plugin need to be in the same plugin base directroy - pluginName.set("aws-toolkit-jetbrains") + projectName = "aws-toolkit-jetbrains" } tasks.withType().all { dependsOn(resharperDllsDir) - intoChild(pluginName.map { "$it/dotnet" }) + intoChild(intellijPlatform.projectName.map { "$it/dotnet" }) .from(resharperDllsDir) } diff --git a/plugins/toolkit/jetbrains-rider/src-232+/software/aws/toolkits/jetbrains/utils/OpenSolutionFileParams.kt b/plugins/toolkit/jetbrains-rider/tst-232+/software/aws/toolkits/jetbrains/utils/OpenSolutionFileParams.kt similarity index 100% rename from plugins/toolkit/jetbrains-rider/src-232+/software/aws/toolkits/jetbrains/utils/OpenSolutionFileParams.kt rename to plugins/toolkit/jetbrains-rider/tst-232+/software/aws/toolkits/jetbrains/utils/OpenSolutionFileParams.kt diff --git a/plugins/toolkit/jetbrains-ultimate/build.gradle.kts b/plugins/toolkit/jetbrains-ultimate/build.gradle.kts index 7e03b8d8dc1..68282360d2b 100644 --- a/plugins/toolkit/jetbrains-ultimate/build.gradle.kts +++ b/plugins/toolkit/jetbrains-ultimate/build.gradle.kts @@ -11,7 +11,14 @@ plugins { id("toolkit-integration-testing") } +intellijToolkit { + ideFlavor.set(IdeFlavor.IU) +} + dependencies { + intellijPlatform { + localPlugin(project(":plugin-core", "pluginZip")) + } compileOnlyApi(project(":plugin-toolkit:jetbrains-core")) compileOnlyApi(project(":plugin-core:jetbrains-ultimate")) @@ -24,11 +31,3 @@ dependencies { // delete when fully split testRuntimeOnly(project(":plugin-core:jetbrains-ultimate")) } - -intellijToolkit { - ideFlavor.set(IdeFlavor.IU) -} - -intellij { - plugins.add(project(":plugin-core")) -} diff --git a/plugins/toolkit/jetbrains-ultimate/src-232+/software/aws/toolkits/jetbrains/remoteDev/caws/UpdateDevfileAction.kt b/plugins/toolkit/jetbrains-ultimate/src-232+/software/aws/toolkits/jetbrains/remoteDev/caws/UpdateDevfileAction.kt index b6a5d776206..d2ec34cc023 100644 --- a/plugins/toolkit/jetbrains-ultimate/src-232+/software/aws/toolkits/jetbrains/remoteDev/caws/UpdateDevfileAction.kt +++ b/plugins/toolkit/jetbrains-ultimate/src-232+/software/aws/toolkits/jetbrains/remoteDev/caws/UpdateDevfileAction.kt @@ -7,8 +7,8 @@ import com.intellij.openapi.actionSystem.ActionUpdateThread import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.PlatformDataKeys +import com.intellij.openapi.application.WriteAction import com.intellij.openapi.application.runReadAction -import com.intellij.openapi.application.runWriteActionAndWait import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.progress.ProgressIndicator import com.intellij.openapi.progress.ProgressManager @@ -51,7 +51,7 @@ class UpdateDevfileAction : AnAction() { getFilePathForDevfile() } - runWriteActionAndWait { + WriteAction.runAndWait { FileDocumentManager.getInstance().saveAllDocuments() } diff --git a/sandbox-all/build.gradle.kts b/sandbox-all/build.gradle.kts index a3de6d379d3..c6527e55636 100644 --- a/sandbox-all/build.gradle.kts +++ b/sandbox-all/build.gradle.kts @@ -1,12 +1,12 @@ // Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 +import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType import software.aws.toolkits.gradle.intellij.IdeFlavor import software.aws.toolkits.gradle.intellij.toolkitIntelliJ plugins { id("toolkit-intellij-plugin") - id("org.jetbrains.intellij") } toolkitIntelliJ.apply { @@ -14,23 +14,22 @@ toolkitIntelliJ.apply { ideFlavor.set(IdeFlavor.values().firstOrNull { it.name == runIdeVariant.orNull } ?: IdeFlavor.IC) } -intellij { - version.set(toolkitIntelliJ.version()) - localPath.set(toolkitIntelliJ.localPath()) - plugins.set( - listOf( - project(":plugin-core"), - project(":plugin-amazonq"), - project(":plugin-toolkit:intellij-standalone"), - ) - ) - - updateSinceUntilBuild.set(false) - instrumentCode.set(false) -} - tasks.buildPlugin { doFirst { throw GradleException("This project does not produce an artifact. Use project-specific command, e.g. :plugin-toolkit:intellij-standalone:runIde") } } + +dependencies { + intellijPlatform { + val type = toolkitIntelliJ.ideFlavor.map { IntelliJPlatformType.fromCode(it.toString()) } + val version = toolkitIntelliJ.version() + + create(type, version) + jetbrainsRuntime() + + localPlugin(project(":plugin-core", "pluginZip")) + localPlugin(project(":plugin-amazonq", "pluginZip")) + localPlugin(project(":plugin-toolkit:intellij-standalone", "pluginZip")) + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 1f6c2d4e89f..2b61e4ea125 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -49,12 +49,15 @@ if (regionEnv.isPresent && bucketEnv.isPresent && prefixEnv.isPresent) { } plugins { - id("com.gradle.enterprise").version("3.15.1") + id("com.gradle.enterprise").version("3.17.5") id("com.github.burrunan.s3-build-cache").version("1.5") } gradleEnterprise { buildScan { + termsOfServiceUrl = "https://gradle.com/help/legal-terms-of-use" + termsOfServiceAgree = "yes" + obfuscation { username { "" } hostname { "" } diff --git a/tmp-all/build.gradle.kts b/tmp-all/build.gradle.kts index 47c3593dadb..ef51e37350c 100644 --- a/tmp-all/build.gradle.kts +++ b/tmp-all/build.gradle.kts @@ -1,26 +1,34 @@ // Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import software.aws.toolkits.gradle.intellij.IdeVersions +import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType +import org.jetbrains.intellij.platform.gradle.TestFrameworkType +import software.aws.toolkits.gradle.intellij.IdeFlavor +import software.aws.toolkits.gradle.intellij.toolkitIntelliJ plugins { - id("org.jetbrains.intellij") + id("toolkit-intellij-plugin") id("toolkit-kotlin-conventions") id("toolkit-testing") } -intellij { - val ideProfile = IdeVersions.ideProfile(project) - version.set(ideProfile.community.version()) - localPath.set(ideProfile.community.localPath()) - plugins.set( - listOf( - project(":plugin-core"), - project(":plugin-amazonq"), - "aws.toolkit:2.19-${ideProfile.shortName}" - ) - ) +intellijToolkit { + ideFlavor.set(IdeFlavor.IC) +} + +dependencies { + intellijPlatform { + val type = toolkitIntelliJ.ideFlavor.map { IntelliJPlatformType.fromCode(it.toString()) } + val version = toolkitIntelliJ.version() + + create(type, version) + jetbrainsRuntime() + + localPlugin(project(":plugin-core", "pluginZip")) + localPlugin(project(":plugin-amazonq", "pluginZip")) + plugin(toolkitIntelliJ.ideProfile().map { "aws.toolkit:2.19-${it.shortName}" }) - updateSinceUntilBuild.set(false) - instrumentCode.set(false) + testFramework(TestFrameworkType.Bundled) + testFramework(TestFrameworkType.JUnit5) + } }