diff --git a/CHANGELOG.md b/CHANGELOG.md index ec64414d58..289ade99eb 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ - Added `PrepareSandboxTask.pluginName` for easier accessing of the plugin directory name - Allow for using non-installer IDEs for plugin verification [#1715](../../issues/1715) - Added `bundledModule()` dependency extension helpers +- Detect and warn about the `kotlinx-coroutines` library in transitive dependencies + +### Changed +- Add IntelliJ Platform v2 product modules to the test classpath ### Fixed diff --git a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/plugins/project/IntelliJPlatformModulePlugin.kt b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/plugins/project/IntelliJPlatformModulePlugin.kt index f8f8a0363a..abe14b5adc 100644 --- a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/plugins/project/IntelliJPlatformModulePlugin.kt +++ b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/plugins/project/IntelliJPlatformModulePlugin.kt @@ -4,6 +4,7 @@ package org.jetbrains.intellij.platform.gradle.plugins.project import org.gradle.api.Plugin import org.gradle.api.Project +import org.gradle.api.artifacts.Configuration import org.gradle.api.attributes.* import org.gradle.api.attributes.java.TargetJvmVersion import org.gradle.api.plugins.JavaPluginExtension @@ -33,22 +34,8 @@ abstract class IntelliJPlatformModulePlugin : Plugin { } with(project.configurations) configurations@{ - val intellijPlatformComposedJarConfiguration = create(Configurations.INTELLIJ_PLATFORM_COMPOSED_JAR) { - extendsFrom( - this@configurations[Configurations.External.IMPLEMENTATION], - this@configurations[Configurations.External.RUNTIME_ONLY], - ) - } - val intellijPlatformDistributionConfiguration = create(Configurations.INTELLIJ_PLATFORM_DISTRIBUTION) - - listOf( - intellijPlatformComposedJarConfiguration, - intellijPlatformDistributionConfiguration, - ).forEach { - it.isCanBeConsumed = true - it.isCanBeResolved = false - - it.attributes { + fun Configuration.applyVariantAttributes() { + attributes { attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.EXTERNAL)) attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category.LIBRARY)) attributeProvider(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, project.provider { @@ -60,6 +47,30 @@ abstract class IntelliJPlatformModulePlugin : Plugin { } } + create( + name = Configurations.INTELLIJ_PLATFORM_COMPOSED_JAR, + description = "IntelliJ Platform final composed Jar archive", + ) { + isCanBeConsumed = true + isCanBeResolved = true + + applyVariantAttributes() + + extendsFrom( + this@configurations[Configurations.External.IMPLEMENTATION], + this@configurations[Configurations.External.RUNTIME_ONLY], + ) + } + create( + name = Configurations.INTELLIJ_PLATFORM_DISTRIBUTION, + description = "IntelliJ Platform distribution Zip archive", + ) { + isCanBeConsumed = true + isCanBeResolved = false + + applyVariantAttributes() + } + val intellijPlatformPluginModuleConfiguration = create( name = Configurations.INTELLIJ_PLATFORM_PLUGIN_MODULE, description = "IntelliJ Platform plugin module", diff --git a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/tasks/VerifyPluginProjectConfigurationTask.kt b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/tasks/VerifyPluginProjectConfigurationTask.kt index c87ec15c11..fbe9b72474 100644 --- a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/tasks/VerifyPluginProjectConfigurationTask.kt +++ b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/tasks/VerifyPluginProjectConfigurationTask.kt @@ -179,7 +179,7 @@ abstract class VerifyPluginProjectConfigurationTask : DefaultTask(), IntelliJPla yield("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") } if (kotlinxCoroutinesLibraryPresent) { - yield("The Kotlin Coroutines library must not be added explicitly to the project as it is already provided with the IntelliJ Platform, see: https://jb.gg/intellij-platform-kotlin-coroutines") + yield("The Kotlin Coroutines library must not be added explicitly to the project nor as a transitive dependency as it is already provided with the IntelliJ Platform, see: https://jb.gg/intellij-platform-kotlin-coroutines") } if (runtimeMetadata.get()["java.vendor"] != "JetBrains s.r.o.") { yield("The currently selected Java Runtime is not JetBrains Runtime (JBR). This may lead to unexpected IDE behaviors. Please use IntelliJ Platform binary release with bundled JBR or define it explicitly with project dependencies or JVM Toolchain, see: https://jb.gg/intellij-platform-with-jbr") diff --git a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/tasks/tasks.kt b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/tasks/tasks.kt index 6b6177902f..36f342dce1 100644 --- a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/tasks/tasks.kt +++ b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/tasks/tasks.kt @@ -4,6 +4,7 @@ package org.jetbrains.intellij.platform.gradle.tasks import org.gradle.api.Project import org.gradle.api.Task +import org.gradle.api.artifacts.component.ModuleComponentIdentifier import org.gradle.api.file.DirectoryProperty import org.gradle.api.plugins.JavaPluginExtension import org.gradle.api.provider.Property @@ -232,15 +233,14 @@ internal fun Project.preconfigureTask(task: T) { if (this is KotlinMetadataAware) { kotlinPluginAvailable.convention(false) - val implementationConfiguration = project.configurations[Configurations.External.IMPLEMENTATION] - val compileOnlyConfiguration = project.configurations[Configurations.External.COMPILE_ONLY] - + val composedJarConfiguration = project.configurations[Configurations.INTELLIJ_PLATFORM_COMPOSED_JAR] kotlinxCoroutinesLibraryPresent.convention(project.provider { - listOf(implementationConfiguration, compileOnlyConfiguration).any { configuration -> - configuration.dependencies.any { - it.group == "org.jetbrains.kotlinx" && it.name.startsWith("kotlinx-coroutines") - } - } + composedJarConfiguration + .resolvedConfiguration + .resolvedArtifacts + .asSequence() + .mapNotNull { it.id.componentIdentifier as? ModuleComponentIdentifier } + .any { it.group == "org.jetbrains.kotlinx" && it.module.startsWith("kotlinx-coroutines") } }) project.pluginManager.withPlugin(Plugins.External.KOTLIN) { diff --git a/src/test/kotlin/org/jetbrains/intellij/platform/gradle/tasks/VerifyPluginProjectConfigurationTaskTest.kt b/src/test/kotlin/org/jetbrains/intellij/platform/gradle/tasks/VerifyPluginProjectConfigurationTaskTest.kt index 9925690b7e..eff99b44ec 100644 --- a/src/test/kotlin/org/jetbrains/intellij/platform/gradle/tasks/VerifyPluginProjectConfigurationTaskTest.kt +++ b/src/test/kotlin/org/jetbrains/intellij/platform/gradle/tasks/VerifyPluginProjectConfigurationTaskTest.kt @@ -272,7 +272,7 @@ class VerifyPluginProjectConfigurationTaskTest : IntelliJPluginTestBase() { build(Tasks.VERIFY_PLUGIN_PROJECT_CONFIGURATION) { assertContains(HEADER, output) assertContains( - "- The Kotlin Coroutines library must not be added explicitly to the project as it is already provided with the IntelliJ Platform, see: https://jb.gg/intellij-platform-kotlin-coroutines", + "- The Kotlin Coroutines library must not be added explicitly to the project nor as a transitive dependency as it is already provided with the IntelliJ Platform, see: https://jb.gg/intellij-platform-kotlin-coroutines", output ) }