diff --git a/CHANGELOG.md b/CHANGELOG.md index 7771141611..afdbabfcd1 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Configure all tasks that extend task classes instead of just those created by the plugin - Make JbrResolver prefer Gradle javaToolchains by `JetBrains s.r.o`, if available. Only otherwise start fetching and running a new one. - Support for Kotlin Coroutines debugging +- Detect and warn if project adds an explicit dependency on Kotlin Coroutines library ### Changed - Disabled caching for `BuildPluginTask` diff --git a/src/main/kotlin/org/jetbrains/intellij/IntelliJPlugin.kt b/src/main/kotlin/org/jetbrains/intellij/IntelliJPlugin.kt index 0e98ca4f04..76c540503a 100644 --- a/src/main/kotlin/org/jetbrains/intellij/IntelliJPlugin.kt +++ b/src/main/kotlin/org/jetbrains/intellij/IntelliJPlugin.kt @@ -803,6 +803,13 @@ abstract class IntelliJPlugin : Plugin { it.targetCompatibility }) pluginVerifierDownloadDir.convention(downloadDirProvider) + kotlinxCoroutinesLibraryPresent.convention(project.provider { + listOf(IMPLEMENTATION_CONFIGURATION_NAME, COMPILE_ONLY_CONFIGURATION_NAME).any { configurationName -> + project.configurations.getByName(configurationName).dependencies.any { + it.group == "org.jetbrains.kotlinx" && it.name.startsWith("kotlinx-coroutines") + } + } + }) kotlinPluginAvailable.convention(project.provider { project.pluginManager.hasPlugin(KOTLIN_GRADLE_PLUGIN_ID) diff --git a/src/main/kotlin/org/jetbrains/intellij/tasks/VerifyPluginConfigurationTask.kt b/src/main/kotlin/org/jetbrains/intellij/tasks/VerifyPluginConfigurationTask.kt index 6e41651a8b..aa98bdf8ea 100644 --- a/src/main/kotlin/org/jetbrains/intellij/tasks/VerifyPluginConfigurationTask.kt +++ b/src/main/kotlin/org/jetbrains/intellij/tasks/VerifyPluginConfigurationTask.kt @@ -128,6 +128,12 @@ abstract class VerifyPluginConfigurationTask @Inject constructor( @get:Internal abstract val pluginVerifierDownloadDir: Property + /** + * This variable represents whether the Kotlin Coroutines library is added explicitly to the project dependencies. + */ + @get:Internal + abstract val kotlinxCoroutinesLibraryPresent: Property + private val context = logCategory() init { @@ -190,6 +196,9 @@ abstract class VerifyPluginConfigurationTask @Inject constructor( if (kotlinPluginAvailable.get() && kotlinVersion >= Version(1, 8, 20) && kotlinVersion < Version(1, 9) && kotlinIncrementalUseClasspathSnapshot.orNull == null) { yield("The Kotlin plugin in version $kotlinVersion used with the Gradle IntelliJ Plugin leads to the 'java.lang.OutOfMemoryError: Java heap space' exception, see: https://jb.gg/intellij-platform-kotlin-oom") } + if (kotlinxCoroutinesLibraryPresent.get()) { + yield("The Kotlin Coroutines library should not be added explicitly to the project as it is already provided with the IntelliJ Platform.") + } }.joinToString("\n") { "- $it" }.takeIf(String::isNotEmpty)?.let { warn( context, diff --git a/src/test/kotlin/org/jetbrains/intellij/tasks/VerifyPluginConfigurationTaskSpec.kt b/src/test/kotlin/org/jetbrains/intellij/tasks/VerifyPluginConfigurationTaskSpec.kt index 882139a7c5..1ebe62f24c 100644 --- a/src/test/kotlin/org/jetbrains/intellij/tasks/VerifyPluginConfigurationTaskSpec.kt +++ b/src/test/kotlin/org/jetbrains/intellij/tasks/VerifyPluginConfigurationTaskSpec.kt @@ -210,6 +210,25 @@ class VerifyPluginConfigurationTaskSpec : IntelliJPluginSpecBase() { } } + @Test + fun `report kotlinx-coroutines dependency`() { + buildFile.groovy( + """ + dependencies { + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.7.1") + } + """.trimIndent() + ) + + build(VERIFY_PLUGIN_CONFIGURATION_TASK_NAME).let { + assertContains(HEADER, it.output) + assertContains( + "- The Kotlin Coroutines library should not be added explicitly to the project as it is already provided with the IntelliJ Platform.", + it.output + ) + } + } + companion object { const val HEADER = "The following plugin configuration issues were found" }